public int countItems() { return e.countItems(); }
private static void promptStgCmt(DicomObject cmtrslt, float seconds) { DicomElement refSOPSq = cmtrslt.get(Tag.ReferencedSOPSequence); System.out.print(refSOPSq.countItems()); System.out.println(" successful"); DicomElement failedSOPSq = cmtrslt.get(Tag.FailedSOPSequence); if (failedSOPSq != null) { System.out.print(failedSOPSq.countItems()); System.out.println(" FAILED!"); } }
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; }
private static void promptStgCmt(DicomObject cmtrslt, float seconds) { DicomElement refSOPSq = cmtrslt.get(Tag.ReferencedSOPSequence); System.out.print(refSOPSq.countItems()); System.out.println(" successful"); DicomElement failedSOPSq = cmtrslt.get(Tag.FailedSOPSequence); if (failedSOPSq != null) { System.out.print(failedSOPSq.countItems()); System.out.println(" FAILED!"); } }
private static int fragsToStringBuffer(DicomElement e, StringBuffer sb, DicomObjectToStringParam param) { int lines = 0; for (int i = 0, n = e.countItems(); i < n; ++i) { if (++lines >= param.numLines) { sb.append("...").append(param.lineSeparator); break; } sb.append(param.indent); sb.append("ITEM #"); sb.append(i + 1); if (i >= param.numItems) { sb.append("...").append(param.lineSeparator); break; } sb.append(" ["); sb.append((e.getFragment(i).length + 1) & ~1); sb.append(" bytes]"); sb.append(param.lineSeparator); } return lines; }
private int calcItemSqLen(DicomElement a) { int l = explicitSequenceLength ? 0 : 8; for (int i = 0, n = a.countItems(); i < n; ++i) { DicomObject item = a.getDicomObject(i); ItemInfo itemInfo = new ItemInfo(item.iterator(), includeGroupLength); if (childs == null) // lazy allocation childs = new LinkedList<ItemInfo>(); childs.add(itemInfo); l += 8 + itemInfo.len; } return l; } }
private static int itemsToStringBuffer(DicomElement e, StringBuffer sb, DicomObjectToStringParam param) { int lines = 0; for (int i = 0, n = e.countItems(); i < n && lines < param.numLines; i++) { if (++lines == param.numLines) { sb.append("...").append(param.lineSeparator);
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; }
/** 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; }
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 boolean visit(DicomElement attr) { if (attr.vr() == VR.SQ && attr.hasItems()) { for (int i = 0, n = attr.countItems(); i < n; ++i) { attr.getDicomObject(i).cachePut(cachePut); } } return true; } });
sb.setLength(maxLen); sb.append(param.lineSeparator); if (e.countItems() > 0) { DicomObjectToStringParam param1 = new DicomObjectToStringParam( param.name, param.valueLength, param.numItems,
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); } } }
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; }
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);
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; } });
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(); }
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); }
: tag; if (attr.hasItems()) { final int n = attr.countItems(); DicomElement t; if (vr == VR.SQ) {