com.pixelmed.dicom
Class DicomOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by com.pixelmed.dicom.BinaryOutputStream
              extended by com.pixelmed.dicom.DicomOutputStream
All Implemented Interfaces:
Closeable, Flushable

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
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
DicomOutputStream(OutputStream o, String metaTransferSyntaxUID, String dataTransferSyntaxUID)
          Construct a stream to write DICOM data sets to the supplied stream.
 
Method Summary
 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, writeUnsigned16, writeUnsigned16, writeUnsigned32, writeUnsigned8
 
Methods inherited from class java.io.FilterOutputStream
close, flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DicomOutputStream

public DicomOutputStream(OutputStream o,
                         String metaTransferSyntaxUID,
                         String dataTransferSyntaxUID)
                  throws 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 to
metaTransferSyntaxUID - use this transfer syntax for the meta information header (may be null)
dataTransferSyntaxUID - use this transfer syntax for the data set
Throws:
IOException
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