/* * Get the contents of an input dataset element by tag, * handling CTP elements specially. * @param tag the element tag * @return the value of the specified element in the current dataset, * @throws Exception if the element is missing. */ public String contents(int tag) throws Exception { SpecificCharacterSet cs = inDS.getSpecificCharacterSet(); // Handle FileMetaInfo references if ((inFMI != null) && ((tag & 0x7FFFFFFF) < 0x80000)) { DcmElement el = inFMI.get(tag); if (el == null) throw new Exception(Tags.toString(tag) + " missing"); return el.getString(cs); } // Not FMI, handle DataSet references boolean ctp = false; if (((tag & 0x00010000) != 0) && ((tag & 0x0000ff00) != 0)) { int blk = (tag & 0xffff0000) | ((tag & 0x0000ff00) >> 8); try { ctp = inDS.getString(blk).equals("CTP"); } catch (Exception notCTP) { ctp = false; } } DcmElement el = inDS.get(tag); if (el == null) throw new Exception(Tags.toString(tag) + " missing"); if (ctp) return new String(inDS.getByteBuffer(tag).array()); String[] s = el.getStrings(cs); if (s.length == 1) return s[0]; if (s.length == 0) return ""; StringBuffer sb = new StringBuffer(s[0]); for (int i = 1; i < s.length; i++) { sb.append("\\" + s[i]); } return sb.toString(); }
public InstanceModel(Dataset ds) { super(ds); ds.setPrivateCreatorID(PrivateTags.CreatorID); ByteBuffer bb = ds.getByteBuffer(PrivateTags.InstancePk); this.pk = bb == null ? -1 : Convert.toLong(bb.array()); }