Class DicomInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
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:
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
ConstructorsConstructorDescriptionDicomInputStream
(File file) Construct a stream to read DICOM data sets from the supplied stream.DicomInputStream
(File file, String transferSyntaxUID, boolean tryMeta) Construct a stream to read DICOM data sets from the supplied stream.Construct a stream to read DICOM data sets from the supplied stream.DicomInputStream
(InputStream i, String transferSyntaxUID, boolean tryMeta) Construct a stream to read DICOM data sets from the supplied stream. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Are we reading the dataset?boolean
Are we reading the meta information header?long
Get the byte offset of the start of the dataset or meta information header.Get the transfer syntax currently in use.Get the transfer syntax to be used for reading the data set.Get the transfer syntax to be used for reading the meta information header.void
boolean
Do we have a meta information header?void
Switch to the transfer syntax for reading the dataset.void
Switch to the transfer syntax for reading the meta information header.void
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
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
DicomInputStream
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:
IOException
- if an I/O error occurs
-
DicomInputStream
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:
IOException
- if an I/O error occurs
-
DicomInputStream
public DicomInputStream(InputStream i, String transferSyntaxUID, boolean tryMeta) throws 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:
IOException
- if an I/O error occurs
-
DicomInputStream
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:
IOException
- if an I/O error occurs
-
-
Method Details
-
guessTransferSyntaxToReadDataSet
- Throws:
IOException
-
setTransferSyntaxToReadDataSet
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
Get the transfer syntax currently in use.
- Returns:
- the transfer syntax
-
getTransferSyntaxToReadDataSet
Get the transfer syntax to be used for reading the data set.
- Returns:
- the transfer syntax
-
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)
-