private boolean matchSQ(DicomElement sq, DicomObject keys, boolean ignoreCaseOfPN) { if (keys.isEmpty()) return true; for (int i = 0, n = sq.countItems(); i < n; i++) { if (sq.getDicomObject(i).matches(keys, ignoreCaseOfPN)) return true; } return false; }
public byte[] getBytes() { return e.getBytes(); }
public String getValueAsString(SpecificCharacterSet cs, int truncate) { return e.getValueAsString(cs, truncate); }
private int calcFragSqLen(DicomElement a) { int l = 8; for (int i = 0, n = a.countItems(); i < n; ++i) { byte[] b = a.getFragment(i); l += 8 + (b.length + 1) & ~1; } return l; }
public boolean visit(DicomElement attr) { if (attr.vr() == VR.SQ && attr.hasItems()) { for (int i = 0, n = attr.countItems(); i < n; ++i) { attr.getDicomObject(i).cacheGet(cacheGet); } } return true; } });
public void add(DicomElement a) { if (a.hasItems()) { final int n = a.countItems(); DicomElement t; if (a.vr() == VR.SQ) { t = putSequence(a.tag(), n); for (int i = 0; i < n; i++) { DicomObject srcItem = a.getDicomObject(i); BasicDicomObject item = new BasicDicomObject(srcItem.size()); item.setParent(this); srcItem.copyTo(item); t.addDicomObject(item); } } else { t = putFragments(a.tag(), a.vr(), a.bigEndian(), n); for (int i = 0; i < n; i++) { t.addFragment(a.getFragment(i)); } } a = t; } addInternal(a); }
DicomElement a = itr.next(); if (groupLength1) { int gggg = a.tag() & 0xffff0000; if (gggg != gggg0) { gggg0 = gggg; final VR vr = a.vr(); int len = a.length(); if (vr == VR.SQ) { if (len == -1 && explicitSequenceLength) { writeHeader(a.tag(), vr, len); a.bigEndian(ts.bigEndian()); if (a.hasItems()) { if (vr == VR.SQ) { for (int i = 0, n = a.countItems(); i < n; i++) { DicomObject item = a.getDicomObject(i); ItemInfo childItemInfo = itemInfo != null ? (ItemInfo) itemInfo.childs .removeFirst() for (int i = 0, n = a.countItems(); i < n; i++) { byte[] val = a.getFragment(i); writeHeader(Tag.Item, null, (val.length + 1) & ~1); write(val); byte[] val = a.getBytes(); write(val); if ((val.length & 1) != 0)
public boolean visit(DicomElement key) { DicomElement el = get(key.tag()); if (el == null) return false; if (key.hasDicomObjects()) { DicomObject itemKeys = key.getDicomObject(); if (itemKeys != null && !itemKeys.isEmpty()) { if (!el.hasDicomObjects() || el.isEmpty()) return false; for (int i = 0, n = el.countItems(); i < n; i++) { if (!el.getDicomObject(i).containsAll(itemKeys)) return false; } } } return true; } });
public boolean visit(DicomElement test) { if (test.isEmpty()) // Universal Matching return true; final int tag = test.tag(); DicomElement attr = get(tag); if (attr == null || attr.isEmpty()) return true; // Missing DicomElement (Value) match always final VR vr = test.vr(); if (vr instanceof VR.Fragment) return true; // ignore OB,OW,OF,UN filter attrs return matchSQ(attr, test.getDicomObject(), ignoreCaseOfPN); return tmTag != 0 ? matchRange(getDates(tag, tmTag), keys .getDateRange(tag, tmTag)) : matchRange(attr .getDates(cacheGet()), test.getDateRange(keys .cacheGet())); : matchRange(attr.getDates(cacheGet()), test .getDateRange(keys.cacheGet())); return matchRange(attr.getDates(cacheGet()), test .getDateRange(keys.cacheGet())); return matchValue(attr.getStrings(getSpecificCharacterSet(), cacheGet()), test.getPattern(keys .getSpecificCharacterSet(), vr == VR.PN ? ignoreCaseOfPN : false, keys.cacheGet()));
private void writeElement(DicomObject attrs, DicomElement a) throws SAXException, IOException { VR vr = a.vr(); final int tag = a.tag(); if (file != null) file = new File(file, StringUtils.intToHex(tag)); String fpath = fpath(tag, vr, a.length()); startAttributeElement(tag, vr, a.length(), fpath, attrs); if (a.hasItems()) { for (int i = 0, n = a.countItems(); i < n; ++i) { writeItem(a, i); } } else { if (fpath != null) { writeToFile(a.getBytes()); } else { vr.formatXMLValue(a.getBytes(), a.bigEndian(), attrs.getSpecificCharacterSet(), cbuf, ch); } } endAttributeElement(); if (file != null) file = file.getParentFile(); }
dcmElmt = (DicomElement) itKeys.next(); if (dcmElmt.isEmpty()) { continue; if (dcmElmt.hasDicomObjects()) { if (dcmElmt.getDicomObject() == null) continue; if (!applyFilter(dcmElmt.getDicomObject(), sObj)) { return false; tag = dcmElmt.tag(); !(byte2string(sObj.get(tag).getBytes()).trim().equals(byte2string(dcmElmt.getBytes()).trim())) ) {
private void writeItem(DicomElement a, int index) throws SAXException, IOException { if (file != null) file = new File(file, Integer.toString(index+1)); if (a.vr() == VR.SQ) { writeContent(a.getDicomObject(index), TAG_ITEM); } else { final byte[] data = a.getFragment(index); writeFragment(a.vr(), data, a.bigEndian(), fpath(a.tag(), a.vr(), data.length)); } if (file != null) file = file.getParentFile(); }
private void readItemValue() throws IOException, DicomCodingException { DicomElement sq = sqStack.get(sqStack.size() - 1); if (vallen == -1) { if (sq.vr() == VR.UN) { DicomElement tmp = attrs.putSequence(sq.tag()); for (int i = 0, n = sq.countItems(); i < n; ++i) { byte[] b = sq.getFragment(i); InputStream is = new ByteArrayInputStream(b); DicomInputStream dis1 = new DicomInputStream(is, DicomObject item = new BasicDicomObject(); dis1.readDicomObject(item, b.length); tmp.addDicomObject(item); if (sq.vr() != VR.SQ) { throw new DicomCodingException(TagUtils.toString(tag) + " " + sq.vr() + " contains item with unknown length."); if (sq.vr() == VR.SQ) { BasicDicomObject item = new BasicDicomObject(); item.setParent(attrs); item.setItemOffset(tagpos); readDicomObject(item, vallen); sq.addDicomObject(item); } else { sq.addFragment(readBytes(vallen));
private void transcodeItem(DicomInputStream in) throws SAXException, IOException { final DicomElement sq = in.sq(); final int itemLen = in.valueLength(); final VR sqvr = sq.vr(); final int index = sq.countItems(); if (file != null) file = new File(file, Integer.toString(index+1)); final String fpath = fpath(sq.tag(), sqvr, itemLen); startItemElement(in.tagPosition(), itemLen, fpath); in.readValue(in); if (sq.hasFragments() && index < sq.countItems()) { byte[] data = sq.getFragment(index); if (fpath != null) { writeToFile(data); } else { final boolean bigEndian = in.getTransferSyntax().bigEndian(); sqvr.formatXMLValue(data, bigEndian, null, cbuf, ch); } sq.setFragment(index, EMPTY_BYTES); // allow gc to release byte[] } endItemElement(); if (file != null) file = file.getParentFile(); }
private DicomObject getItem(int[] itemPath, int pathLen, boolean readonly) { DicomObject item = this; for (int i = 0; i < pathLen; ++i, ++i) { DicomElement sq = item.get(itemPath[i]); if (sq == null || !sq.hasItems()) { if (readonly) { return null; } sq = item.putSequence(itemPath[i]); } while (sq.countItems() <= itemPath[i + 1]) { if (readonly) { return null; } sq.addDicomObject(new BasicDicomObject()); } item = sq.getDicomObject(itemPath[i + 1]); } return item; }
/** Checks to see if the given DICOM object has any skipped elementss * and combined them into a list. * @param ds * @param ret is null initially and a list is created as required * @return */ public static List<SkippedDicomElement> checkHasSkippedElement(DicomObject ds, List<SkippedDicomElement> ret) { Iterator<DicomElement> it = ds.iterator(); while(it.hasNext()) { DicomElement de = it.next(); if( de instanceof SkippedDicomElement ) { if( ret==null ) ret = new ArrayList<SkippedDicomElement>(); ret.add((SkippedDicomElement) de); } else if( de.hasDicomObjects()) { int n = de.countItems(); for(int i=0; i<n; i++) { ret = checkHasSkippedElement(de.getDicomObject(i),ret); } } } return ret; }
private void copyConceptNameModifiers(DicomObject dcmobj, DicomObject rec) { DicomElement objsq = dcmobj.get(Tag.ContentSequence); if (objsq == null) { return; } DicomElement recsq = null; DicomObject item; for (int i = 0, n = objsq.countItems(); i < n; i++) { item = objsq.getDicomObject(i); if ("HAS CONCEPT MOD".equals(item.getString(Tag.RelationshipType))) { if (recsq == null) { // lazy sequence creation recsq = rec.putSequence(Tag.ContentSequence); } recsq.addDicomObject(item); } } }
String add = ""; if (e != null) { add = new String(e.getBytes()); if (!element.isEmpty()) if (!ElementDictionary.getDictionary().nameOf(element.tag()).contains("Sequence")) queryParams += ElementDictionary.getDictionary().nameOf(element.tag()) + " - " + element.getValueAsString(new SpecificCharacterSet("UTF-8"), 0) + " ";
e.toStringBuffer(sb, param.valueLength); if (param.name) { sb.append(" "); sb.append(nameOf(e.tag())); if (e.countItems() > 0) { DicomObjectToStringParam param1 = new DicomObjectToStringParam( param.name, param.valueLength, param.numItems, param.lineLength, param.numLines - lines, param.indent + '>', param.lineSeparator); if (e.hasDicomObjects()) lines += itemsToStringBuffer(e, sb, param1); else