Class DicomOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- com.pixelmed.dicom.BinaryOutputStream
-
- com.pixelmed.dicom.DicomOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class DicomOutputStream extends BinaryOutputStream
A class that extends
BinaryOutputStream
by adding the concept of transfer syntaxes, for a (possible) meta information header and a data set.Note this class does not automatically switch from meta information header to data set transfer syntaxes. That is the responsibility of the caller writing the individual attributes (such as by reaching the end of the meta information group length, and then calling
setWritingDataSet()
.- See Also:
AttributeList
,DicomInputStream
-
-
Field Summary
-
Fields inherited from class com.pixelmed.dicom.BinaryOutputStream
byteOffset
-
-
Constructor Summary
Constructors Constructor Description DicomOutputStream(java.io.OutputStream o, java.lang.String metaTransferSyntaxUID, java.lang.String dataTransferSyntaxUID)
Construct a stream to write DICOM data sets to the supplied stream.DicomOutputStream(java.io.OutputStream o, java.lang.String metaTransferSyntaxUID, java.lang.String dataTransferSyntaxUID, byte[] preamble)
Construct a stream to write DICOM data sets to the supplied stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
areWritingDataSet()
Are we writing the dataset?boolean
areWritingMetaHeader()
Are we writing the meta information header?long
getByteOffsetOfStartOfData()
Get the byte offset of the start of the dataset or meta information header.TransferSyntax
getTransferSyntaxInUse()
Get the transfer syntax currently in use.TransferSyntax
getTransferSyntaxToWriteDataSet()
Get the transfer syntax to be used for writing the data set.TransferSyntax
getTransferSyntaxToWriteMetaHeader()
Get the transfer syntax to be used for writing the meta information header.boolean
haveMetaHeader()
Will we be writing a meta information header?boolean
isExplicitVR()
Is the transfer syntax currently in use explicit VR ?boolean
isImplicitVR()
Is the transfer syntax currently in use implicit VR ?void
setTransferSyntaxToWriteDataSet(TransferSyntax ts)
Specify what transfer syntax to use when switching from writing the meta information header to writing the data set.void
setWritingDataSet()
Switch to the transfer syntax for writing the dataset.void
setWritingMetaHeader()
Switch to the transfer syntax for writing the meta information header.-
Methods inherited from class com.pixelmed.dicom.BinaryOutputStream
getByteOffset, isBigEndian, isLittleEndian, localInit, main, setBigEndian, setEndian, setLittleEndian, write, write, write, writeDouble, writeDouble, writeFloat, writeFloat, writeSigned16, writeSigned32, writeSigned64, writeUnsigned16, writeUnsigned16, writeUnsigned32, writeUnsigned32, writeUnsigned64, writeUnsigned64, writeUnsigned8
-
-
-
-
Constructor Detail
-
DicomOutputStream
public DicomOutputStream(java.io.OutputStream o, java.lang.String metaTransferSyntaxUID, java.lang.String dataTransferSyntaxUID) throws java.io.IOException
Construct a stream to write DICOM data sets to the supplied stream.
If the metaTransferSyntaxUID is not null, a 128 byte preamble of all zeroes plus "DICM" will also be written.
- Parameters:
o
- the output stream to write tometaTransferSyntaxUID
- use this transfer syntax for the meta information header (may be null)dataTransferSyntaxUID
- use this transfer syntax for the data set- Throws:
java.io.IOException
- if an I/O error occurs
-
DicomOutputStream
public DicomOutputStream(java.io.OutputStream o, java.lang.String metaTransferSyntaxUID, java.lang.String dataTransferSyntaxUID, byte[] preamble) throws java.io.IOException
Construct a stream to write DICOM data sets to the supplied stream.
If the metaTransferSyntaxUID is not null, a 128 byte preamble plus "DICM" will also be written.
- Parameters:
o
- the output stream to write tometaTransferSyntaxUID
- use this transfer syntax for the meta information header (may be null)dataTransferSyntaxUID
- use this transfer syntax for the data setpreamble
- 128 bytes to use as preamble, otherwise null to use default of all zero bytes- Throws:
java.io.IOException
- if an I/O error occurs
-
-
Method Detail
-
setTransferSyntaxToWriteDataSet
public void setTransferSyntaxToWriteDataSet(TransferSyntax ts)
Specify what transfer syntax to use when switching from writing the meta information header to writing the data set.
- Parameters:
ts
- transfer syntax to use for data set
-
setWritingDataSet
public void setWritingDataSet()
Switch to the transfer syntax for writing the dataset.
-
areWritingDataSet
public boolean areWritingDataSet()
Are we writing the dataset?
- Returns:
- true if writing the dataset, false if reading the meta information header
-
setWritingMetaHeader
public void setWritingMetaHeader()
Switch to the transfer syntax for writing the meta information header.
-
areWritingMetaHeader
public boolean areWritingMetaHeader()
Are we writing the meta information header?
- Returns:
- true if writing the meta information header, false if writing the dataset
-
haveMetaHeader
public boolean haveMetaHeader()
Will we be writing a meta information header?
- Returns:
- true if there is a meta information header, false if not
-
getTransferSyntaxInUse
public TransferSyntax getTransferSyntaxInUse()
Get the transfer syntax currently in use.
- Returns:
- the transfer syntax
-
getTransferSyntaxToWriteDataSet
public TransferSyntax getTransferSyntaxToWriteDataSet()
Get the transfer syntax to be used for writing the data set.
- Returns:
- the transfer syntax
-
getTransferSyntaxToWriteMetaHeader
public TransferSyntax getTransferSyntaxToWriteMetaHeader()
Get the transfer syntax to be used for writing the meta information header.
- Returns:
- the transfer syntax
-
getByteOffsetOfStartOfData
public long getByteOffsetOfStartOfData()
Get the byte offset of the start of the dataset or meta information header.
Will be 0 if no preamble, 132 if a preamble.
- Returns:
- the byte offset (from 0 being the start of the stream)
-
isExplicitVR
public boolean isExplicitVR()
Is the transfer syntax currently in use explicit VR ?
- Returns:
- true if explicit VR, false if implicit VR
-
isImplicitVR
public boolean isImplicitVR()
Is the transfer syntax currently in use implicit VR ?
- Returns:
- true if implicit VR, false if explicit VR
-
-