DicomOutputStream extends OutputStream { public void writeDataSet(DicomObject dcmobj) throws IOException { if (encoding == null) throw new IllegalStateException("encoding not initialized"); Objects.requireNonNull(dcmobj); if (includeGroupLength || itemLengthEncoding.calculate || sequenceLengthEncoding.calculate) { ((DicomObjectImpl) dcmobj).calculateItemLength(this); } ((DicomObjectImpl) dcmobj).writeTo(this); if (out instanceof DeflaterOutputStream) { ((DeflaterOutputStream) out).finish(); } } DicomOutputStream(OutputStream out); DicomEncoding getEncoding(); DicomOutputStream withEncoding(DicomEncoding encoding); DicomOutputStream withEncoding(DicomObject fmi); boolean isIncludeGroupLength(); DicomOutputStream withIncludeGroupLength(boolean includeGroupLength); LengthEncoding getItemLengthEncoding(); DicomOutputStream withItemLengthEncoding(LengthEncoding itemLengthEncoding); LengthEncoding getSequenceLengthEncoding(); DicomOutputStream withSequenceLengthEncoding(LengthEncoding sequenceLengthEncoding); @Override void write(int b); @Override void write(byte[] b, int off, int len); @Override void flush(); @Override void close(); void writeHeader(int tag, VR vr, int length); DicomOutputStream writeFileMetaInformation(DicomObject fmi); void writeDataSet(DicomObject dcmobj); void writeCommandSet(DicomObject dcmobj); byte[] swapBuffer(); void writeUTF(String s);  }
@Test void writeSequenceIVR_LE() throws IOException { assertArrayEquals(IVR_LE, writeDataset(DicomEncoding.IVR_LE, false, DicomOutputStream.LengthEncoding.UNDEFINED_OR_ZERO, DicomOutputStream.LengthEncoding.UNDEFINED_OR_ZERO, sequences())); }
@Test void writeSequenceEVR_BE_GROUP() throws IOException { assertArrayEquals(EVR_BE_GROUP, writeDataset(DicomEncoding.EVR_BE, true, DicomOutputStream.LengthEncoding.UNDEFINED_OR_ZERO, DicomOutputStream.LengthEncoding.UNDEFINED_OR_ZERO, sequences())); }
@Test void writeSequenceExplicitItemLength() throws IOException { assertArrayEquals(EXPL_ITEM_LEN, writeDataset(DicomEncoding.IVR_LE, true, DicomOutputStream.LengthEncoding.UNDEFINED, DicomOutputStream.LengthEncoding.EXPLICIT, sequences())); }
@Test void writeSequenceExplicitSequenceLength() throws IOException { assertArrayEquals(EXPL_SEQ_LEN, writeDataset(DicomEncoding.IVR_LE, true, DicomOutputStream.LengthEncoding.EXPLICIT, DicomOutputStream.LengthEncoding.UNDEFINED, sequences())); }
@Test void withBulkDataURI() throws IOException { String baseURL = DicomInputStreamTest.resource("waveform_overlay_pixeldata.dcm").toString(); DicomObject data = DicomObject.newDicomObject(); DicomElement seq = data.newDicomSequence(Tag.WaveformSequence); DicomObject item = DicomObject.newDicomObject(); seq.addItem(item); item.setBulkData(Tag.WaveformData, VR.OW, baseURL + "#offset=32&length=256", null); data.setBulkData(Tag.OverlayData, VR.OW, baseURL + "#offset=300&length=256", null); data.setBulkData(Tag.PixelData, VR.OB, baseURL + "#offset=568", null); data.setNull(Tag.DataSetTrailingPadding, VR.OB); assertArrayEquals(resourceAsBytes("waveform_overlay_pixeldata.dcm"), writeDataset(DicomEncoding.EVR_LE, false, DicomOutputStream.LengthEncoding.EXPLICIT, DicomOutputStream.LengthEncoding.EXPLICIT, data)); }