public Range(DicomObject attrs, int fromTag, int toTag) { super(attrs); if ((fromTag & 0xffffffffL) > (toTag & 0xffffffffL)) { throw new IllegalArgumentException("fromTag:" + TagUtils.toString(fromTag) + " > toTag:" + TagUtils.toString(toTag)); } this.fromTag = fromTag & 0xffffffffL; this.toTag = toTag & 0xffffffffL; if (this.fromTag > this.toTag) { throw new IllegalArgumentException("fromTag:" + TagUtils.toString(fromTag) + " > toTag:" + TagUtils.toString(toTag)); } }
public static DicomObject getLUT(DicomObject dobj, int sqTag) { DicomObject lut = dobj.getNestedDicomObject(sqTag); if (lut != null) { if (!lut.containsValue(Tag.LUTData)) { log.info("Ignore " + TagUtils.toString(sqTag) + " with missing LUT Data (0028,3006)"); return null; } if (!lut.containsValue(Tag.LUTDescriptor)) { log.info("Ignore " + TagUtils.toString(sqTag) + " with missing LUT Descriptor (0028,3002)"); return null; } } return lut; }
public String getPrivateCreator(int tag) { if (!TagUtils.isPrivateDataElement(tag) || TagUtils.isPrivateCreatorDataElement(tag)) throw new IllegalArgumentException(TagUtils.toString(tag)); int creatorIDtag = (tag & 0xffff0000) | ((tag >> 8) & 0xff); return getAndCacheString(creatorIDtag); }
public int resolveTag(int tag, String creator, boolean reserve) { if (creator == null || !TagUtils.isPrivateDataElement(tag)) return tag; int gggg0000 = tag & 0xffff0000; int idTag = gggg0000 | 0x10; int maxIdTag = gggg0000 | 0xff; String id; while (!creator.equals(id = getAndCacheString(idTag))) { if (id == null) { if (!reserve) return -1; addPrivateCreator(creator, idTag); break; } if (++idTag > maxIdTag) throw new IllegalStateException( "No free block to reserve in group " + TagUtils.toString(gggg0000)); } return (tag & 0xffff00ff) | ((idTag & 0xff) << 8); }
public void readItem(DicomObject dest) throws IOException { dest.setItemOffset(pos); if (readHeader() != Tag.Item) throw new DicomCodingException("Expected (FFFE,E000) but read " + TagUtils.toString(tag)); readDicomObject(dest, vallen); }
private long endPos() throws IOException { if (recordSeqLen == -1) { long endPos = raf.length() - 12; raf.seek(endPos); if (in.readHeader() == Tag.SequenceDelimitationItem) { recordSeqLen = (int) (endPos - firstRecordPos); } else { endPos = filesetInfo.getOffsetLastRootRecord(); raf.seek(endPos); in.setStreamPosition(endPos); DicomObject dcmobj = new BasicDicomObject(); while (in.readHeader() == Tag.Item) { in.readDicomObject(dcmobj, in.valueLength()); dcmobj.clear(); endPos = in.getStreamPosition(); } if (in.tag() != Tag.SequenceDelimitationItem) { throw new IOException("Unexpected Tag " + TagUtils.toString(in.tag()) + " at offset " + endPos); } recordSeqLen = (int) (endPos - firstRecordPos); } } return firstRecordPos + recordSeqLen; }
throw new DicomCodingException(TagUtils.toString(tag) + " " + sq.vr() + " contains item with unknown length.");