Class DicomInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- com.pixelmed.dicom.BinaryInputStream
-
- com.pixelmed.dicom.DicomInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class DicomInputStream extends BinaryInputStream
A class that extends
BinaryInputStream
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 parsing the individual attributes (such as by reaching the end of the meta information group length, and then calling
setReadingDataSet()
.- See Also:
AttributeList
,DicomOutputStream
-
-
Constructor Summary
Constructors Constructor Description DicomInputStream(java.io.File file)
Construct a stream to read DICOM data sets from the supplied stream.DicomInputStream(java.io.File file, java.lang.String transferSyntaxUID, boolean tryMeta)
Construct a stream to read DICOM data sets from the supplied stream.DicomInputStream(java.io.InputStream i)
Construct a stream to read DICOM data sets from the supplied stream.DicomInputStream(java.io.InputStream i, java.lang.String transferSyntaxUID, boolean tryMeta)
Construct a stream to read DICOM data sets from the supplied stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
areReadingDataSet()
Are we reading the dataset?boolean
areReadingMetaHeader()
Are we reading 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
getTransferSyntaxToReadDataSet()
Get the transfer syntax to be used for reading the data set.TransferSyntax
getTransferSyntaxToReadMetaHeader()
Get the transfer syntax to be used for reading the meta information header.void
guessTransferSyntaxToReadDataSet()
boolean
haveMetaHeader()
Do we have a meta information header?void
setReadingDataSet()
Switch to the transfer syntax for reading the dataset.void
setReadingMetaHeader()
Switch to the transfer syntax for reading the meta information header.void
setTransferSyntaxToReadDataSet(TransferSyntax ts)
Specify what transfer syntax to use when switching from reading the meta information header to reading the data set.-
Methods inherited from class com.pixelmed.dicom.BinaryInputStream
getFile, isBigEndian, isLittleEndian, main, readComplexDouble, readComplexFloat, readDouble, readDouble, readFloat, readFloat, readInsistently, readSigned16, readSigned32, readSigned64, readUnsigned16, readUnsigned16, readUnsigned16, readUnsigned32, readUnsigned32, readUnsigned32, readUnsigned64, readUnsigned64, readUnsigned64, readUnsigned8, setBigEndian, setEndian, setFile, setLittleEndian, skipInsistently
-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, read, reset, skip
-
-
-
-
Constructor Detail
-
DicomInputStream
public DicomInputStream(java.io.InputStream i) throws java.io.IOException
Construct a stream to read DICOM data sets from the supplied stream.
Look for a meta information header; if absent guess at a transfer syntax based on the contents.
- Parameters:
i
- the input stream to read from- Throws:
java.io.IOException
- if an I/O error occurs
-
DicomInputStream
public DicomInputStream(java.io.File file) throws java.io.IOException
Construct a stream to read DICOM data sets from the supplied stream.
Look for a meta information header; if absent guess at a transfer syntax based on the contents.
- Parameters:
file
- the file to read from- Throws:
java.io.IOException
- if an I/O error occurs
-
DicomInputStream
public DicomInputStream(java.io.InputStream i, java.lang.String transferSyntaxUID, boolean tryMeta) throws java.io.IOException
Construct a stream to read DICOM data sets from the supplied stream.
- Parameters:
i
- the input stream to read fromtransferSyntaxUID
- use this transfer syntax (may be null)tryMeta
- if true, try to find a meta information header- Throws:
java.io.IOException
- if an I/O error occurs
-
DicomInputStream
public DicomInputStream(java.io.File file, java.lang.String transferSyntaxUID, boolean tryMeta) throws java.io.IOException
Construct a stream to read DICOM data sets from the supplied stream.
- Parameters:
file
- the file to read fromtransferSyntaxUID
- use this transfer syntax (may be null)tryMeta
- if true, try to find a meta information header- Throws:
java.io.IOException
- if an I/O error occurs
-
-
Method Detail
-
guessTransferSyntaxToReadDataSet
public void guessTransferSyntaxToReadDataSet() throws java.io.IOException
- Throws:
java.io.IOException
-
setTransferSyntaxToReadDataSet
public void setTransferSyntaxToReadDataSet(TransferSyntax ts)
Specify what transfer syntax to use when switching from reading the meta information header to reading the data set.
- Parameters:
ts
- transfer syntax to use for data set
-
setReadingDataSet
public void setReadingDataSet()
Switch to the transfer syntax for reading the dataset.
-
areReadingDataSet
public boolean areReadingDataSet()
Are we reading the dataset?
- Returns:
- true if reading the dataset, false if reading the meta information header
-
setReadingMetaHeader
public void setReadingMetaHeader()
Switch to the transfer syntax for reading the meta information header.
-
areReadingMetaHeader
public boolean areReadingMetaHeader()
Are we reading the meta information header?
- Returns:
- true if reading the meta information header, false if reading the dataset
-
haveMetaHeader
public boolean haveMetaHeader()
Do we have 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
-
getTransferSyntaxToReadDataSet
public TransferSyntax getTransferSyntaxToReadDataSet()
Get the transfer syntax to be used for reading the data set.
- Returns:
- the transfer syntax
-
getTransferSyntaxToReadMetaHeader
public TransferSyntax getTransferSyntaxToReadMetaHeader()
Get the transfer syntax to be used for reading 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)
-
-