com.pixelmed.dicom
Class DicomInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.pixelmed.dicom.BinaryInputStream
              extended by com.pixelmed.dicom.DicomInputStream
All Implemented Interfaces:
Closeable

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

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
DicomInputStream(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.
DicomInputStream(InputStream i)
          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
 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.
 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, readUnsigned16, readUnsigned16, readUnsigned16, readUnsigned32, 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.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DicomInputStream

public DicomInputStream(InputStream i)
                 throws 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:
IOException

DicomInputStream

public DicomInputStream(File file)
                 throws 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:
IOException

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 from
transferSyntaxUID - use this transfer syntax (may be null)
tryMeta - if true, try to find a meta information header
Throws:
IOException

DicomInputStream

public DicomInputStream(File file,
                        String transferSyntaxUID,
                        boolean tryMeta)
                 throws IOException

Construct a stream to read DICOM data sets from the supplied stream.

Parameters:
file - the file to read from
transferSyntaxUID - use this transfer syntax (may be null)
tryMeta - if true, try to find a meta information header
Throws:
IOException
Method Detail

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)