private void writeFragment(VR vr, byte[] bytes, boolean bigEndian, String fpath) throws SAXException, IOException { startItemElement(-1, (bytes.length + 1) & ~1, fpath); if (fpath != null) { writeToFile(bytes); } else { vr.formatXMLValue(bytes, bigEndian, null, cbuf, ch); } endItemElement(); }
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 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(); }
writeToFile(val); } else { vr.formatXMLValue(val, bigEndian, attrs.getSpecificCharacterSet(), cbuf, ch);