public ContentHandlerAdapter(Attributes attrs) { if (attrs == null) throw new NullPointerException(); items.add(attrs); bigEndian = attrs.bigEndian(); }
public boolean bigEndian() { return getAttributes().bigEndian(); } }
private void setParent(Collection<? extends Attributes> c) { boolean bigEndian = parent.bigEndian(); for (Attributes attrs : c) { if (attrs.bigEndian() != bigEndian) throw new IllegalArgumentException( "Endian of Item must match Endian of parent Data Set"); if (!attrs.isRoot()) throw new IllegalArgumentException( "Item already contained by Sequence"); } for (Attributes attrs : c) attrs.setParent(parent); }
private void bulkData(String uuid, String uri) { bulkData = new BulkData(uuid, uri, items.getLast().bigEndian()); }
private LookupTable createLUT(StoredValue inBits, Attributes attrs) { if (attrs == null) return null; return createLUT(inBits, attrs.getInts(Tag.LUTDescriptor), attrs.getSafeBytes(Tag.LUTData), attrs.bigEndian()); }
private LookupTable createLUT(StoredValue inBits, Attributes attrs) { if (attrs == null) return null; return createLUT(inBits, attrs.getInts(Tag.LUTDescriptor), attrs.getSafeBytes(Tag.LUTData), attrs.bigEndian()); }
public void writeDataset(Attributes fmi, Attributes dataset) throws IOException { if (fmi != null) writeFileMetaInformation(fmi); if (dataset.bigEndian() != bigEndian || encOpts.groupLength || !encOpts.undefSequenceLength || !encOpts.undefItemLength) dataset = new Attributes(dataset, bigEndian); if (encOpts.groupLength) dataset.calcLength(encOpts, explicitVR); dataset.writeTo(this); }
private byte[] lutData(Attributes ds, int[] desc, int dataTag, int segmTag) { int len = desc[0] == 0 ? 0x10000 : desc[0]; int bits = desc[2]; byte[] data = ds.getSafeBytes(dataTag); if (data == null) { int[] segm = ds.getInts(segmTag); if (segm == null) { throw new IllegalArgumentException("Missing LUT Data!"); } if (bits == 8) { throw new IllegalArgumentException( "Segmented LUT Data with LUT Descriptor: bits=8"); } data = new byte[len]; inflateSegmentedLut(segm, data); } else if (bits == 16 || data.length != len) { if (data.length != len << 1) lutLengthMismatch(data.length, len); int hilo = ds.bigEndian() ? 0 : 1; if (bits == 8) hilo = 1 - hilo; // padded high bits -> use low bits data = LookupTableFactory.halfLength(data, hilo); } return data; }
private void writeAttribute(int tag, VR vr, Object value, SpecificCharacterSet cs, Attributes attrs) throws SAXException { if (TagUtils.isGroupLength(tag) || TagUtils.isPrivateCreator(tag)) return; String privateCreator = attrs.getPrivateCreator(tag); addAttributes(tag, vr, privateCreator); startElement("DicomAttribute"); if (value instanceof Value) writeAttribute((Value) value, attrs.bigEndian()); else if (!vr.isInlineBinary()) { writeValues(vr, value, attrs.bigEndian(), attrs.getSpecificCharacterSet(vr)); } else if (value instanceof byte[]) { writeInlineBinary(attrs.bigEndian() ? vr.toggleEndian((byte[]) value, true) : (byte[]) value); } else throw new IllegalArgumentException("vr: " + vr + ", value class: " + value.getClass()); endElement("DicomAttribute"); }
private void writeAttribute(int tag, VR vr, Object value, SpecificCharacterSet cs, Attributes attrs) { if (TagUtils.isGroupLength(tag)) return; gen.writeStartObject(TagUtils.toHexString(tag)); gen.write("vr", vr.name()); if (value instanceof Value) writeValue((Value) value, attrs.bigEndian()); else writeValue(vr, value, attrs.bigEndian(), attrs.getSpecificCharacterSet(vr), true); gen.writeEnd(); }
sb.append(" ["); vr.vr.prompt(value, attrs.bigEndian(), attrs.getSpecificCharacterSet(vr.vr), 200, sb); sb.append(']');
private byte[] lutData(Attributes ds, int[] desc, int dataTag, int segmTag) { int len = desc[0] == 0 ? 0x10000 : desc[0]; int bits = desc[2]; byte[] data = ds.getSafeBytes(dataTag); if (data == null) { int[] segm = ds.getInts(segmTag); if (segm == null) { throw new IllegalArgumentException("Missing LUT Data!"); } if (bits == 8) { throw new IllegalArgumentException( "Segmented LUT Data with LUT Descriptor: bits=8"); } data = new byte[len]; inflateSegmentedLut(segm, data); } else if (bits == 16 || data.length != len) { if (data.length != len << 1) lutLengthMismatch(data.length, len); int hilo = ds.bigEndian() ? 0 : 1; if (bits == 8) hilo = 1 - hilo; // padded high bits -> use low bits data = LookupTableFactory.halfLength(data, hilo); } return data; }
@Override public void readValue(DicomInputStream dis, Sequence seq) throws IOException { checkIsThis(dis); if (length == 0) { seq.add(new Attributes(seq.getParent().bigEndian(), 0)); return; } Attributes attrs = new Attributes(seq.getParent().bigEndian()); seq.add(attrs); readAttributes(attrs, length, Tag.ItemDelimitationItem); attrs.trimToSize(); }
byteBuffer.order(dcm.bigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
audioFormat = new AudioFormat("AB".equals(spInterpretation) ? Encoding.ALAW : Encoding.ULAW, //$NON-NLS-1$ (float) sampleRate, bitsPerSample, numChannels, frameSize, (float) sampleRate, attributes.bigEndian()); } else { boolean signed = "UB".equals(spInterpretation) || "US".equals(spInterpretation) ? false : true; //$NON-NLS-1$ //$NON-NLS-2$ audioFormat = new AudioFormat((float) sampleRate, bitsPerSample, numChannels, signed, attributes.bigEndian());
public void setPresentationLUT(Attributes attrs) { Attributes pLUT = attrs.getNestedDataset(Tag.PresentationLUTSequence); if (pLUT != null) { int[] desc = pLUT.getInts(Tag.LUTDescriptor); if (desc != null && desc.length == 3) { int len = desc[0] == 0 ? 0x10000 : desc[0]; presentationLUT = createLUT(new StoredValue.Unsigned(log2(len)), resetOffset(desc), pLUT.getSafeBytes(Tag.LUTData), pLUT.bigEndian()); } } else { String pShape = attrs.getString(Tag.PresentationLUTShape); inverse = (pShape != null ? "INVERSE".equals(pShape) : "MONOCHROME1".equals( attrs.getString(Tag.PhotometricInterpretation))); } }
public void setPresentationLUT(Attributes attrs) { Attributes pLUT = attrs.getNestedDataset(Tag.PresentationLUTSequence); if (pLUT != null) { int[] desc = pLUT.getInts(Tag.LUTDescriptor); if (desc != null && desc.length == 3) { int len = desc[0] == 0 ? 0x10000 : desc[0]; presentationLUT = createLUT(new StoredValue.Unsigned(log2(len)), resetOffset(desc), pLUT.getSafeBytes(Tag.LUTData), pLUT.bigEndian()); } } else { String pShape = attrs.getString(Tag.PresentationLUTShape); inverse = (pShape != null ? "INVERSE".equals(pShape) : "MONOCHROME1".equals( attrs.getString(Tag.PhotometricInterpretation))); } }
private void readFragments(Attributes attrs, int fragsTag, VR vr) throws IOException { Fragments frags = new Fragments(vr, attrs.bigEndian(), 10); String privateCreator = attrs.getPrivateCreator(fragsTag); for (int i = 0; readItemHeader(); ++i) { addItemPointer(fragsTag, privateCreator, i); handler.readValue(this, frags); removeItemPointer(); } if (frags.isEmpty()) attrs.setNull(fragsTag, vr); else { frags.trimToSize(); attrs.setValue(fragsTag, vr, frags); } }
@Override public void readValue(DicomInputStream dis, Attributes attrs) throws IOException { checkIsThis(dis); if (excludeBulkData) { skipFully(length); } else if (length == 0) { attrs.setNull(tag, vr); } else if (vr == VR.SQ) { readSequence(length, attrs, tag); } else if (length == -1) { readFragments(attrs, tag, vr); } else if (length == BulkData.MAGIC_LEN && super.in instanceof ObjectInputStream) { attrs.setValue(tag, vr, BulkData.deserializeFrom( (ObjectInputStream) super.in)); } else if (includeBulkDataURI) { attrs.setValue(tag, vr, bulkDataCreator.createBulkData(this)); } else { byte[] b = readValue(); if (!TagUtils.isGroupLength(tag)) { if (bigEndian != attrs.bigEndian()) vr.toggleEndian(b, false); attrs.setBytes(tag, vr, b); } else if (tag == Tag.FileMetaInformationGroupLength) setFileMetaInformationGroupLength(b); } }