org.dicom4j.io
Class BinaryInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.dicom4j.io.BinaryInputStream
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
DicomInputStream

public class BinaryInputStream
extends FilterInputStream

Extends FilterInputStream by adding the concept of little and big endian binary value encoding.

Since:
0.0.0
Author:
Laurent Lecomte
See Also:
BinaryOutputStream

Constructor Summary
BinaryInputStream(InputStream aInput)
           Construct a new stream from the supplied stream (byte order: LITTLE_ENDIAN).
BinaryInputStream(InputStream i, ByteOrder aByteOrder)
           Construct a new stream from the supplied stream.
 
Method Summary
 ByteOrder getByteOrder()
           
 int read(byte[] aBytes)
          TODO
 String readASCII(int aLength)
          Read string coded in ACSII
 boolean readBoolean()
          Reads one byte and returns true if that byte is nonzero, false if that byte is zero.
 byte readByte()
          Read one byte
 void readComplexDouble(double[] freal, double[] fimaginary, int len)
           Read interleaved complex floating point 64 bit value pairs into real and imaginary arrays.
 void readComplexFloat(float[] freal, float[] fimaginary, int len)
           Read interleaved complex floating point 32 bit value pairs into real and imaginary arrays.
 double readDouble()
           Read one floating point 64 bit value.
 void readDouble(double[] f, int len)
           Read an array of floating point 64 bit values.
 float readFloat()
           Read one floating point 32 bit value.
 void readFloat(float[] f, int len)
           Read an array of floating point 32 bit values.
 void readFully(byte[] arg0)
           
 void readFully(byte[] arg0, int arg1, int arg2)
           
 void readInsistently(byte[] b, int offset, int length)
           Read as many bytes as requested, unless an exception occurs.
 int readSigned16()
           Read one signed integer 16 bit value.
 int readSigned32()
           Read one signed integer 32 bit value.
 String readString(int aLength, String aCharsetName)
          read string coded in a specific charset
 int readUnsigned16()
           Read one unsigned integer 16 bit value.
 void readUnsigned16(short[] w, int len)
           Read an array of unsigned integer 16 bit values.
 void readUnsigned16(short[] w, int offset, int len)
           Read an array of unsigned integer 16 bit values.
 long readUnsigned32()
           Read one unsigned integer 32 bit value.
 int readUnsigned8()
           Read one unsigned integer 8 bit value.
 int readUnsignedByte()
           
 int readUnsignedShort()
           
 void setByteOrder(ByteOrder aByteOrder)
           
 long skip(long aNumberToSkip)
          Skips over and discards n bytes of data from the input stream.
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, reset
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryInputStream

public BinaryInputStream(InputStream aInput)

Construct a new stream from the supplied stream (byte order: LITTLE_ENDIAN).

Parameters:
aInput - the input stream to read from

BinaryInputStream

public BinaryInputStream(InputStream i,
                         ByteOrder aByteOrder)

Construct a new stream from the supplied stream.

Parameters:
aInput - the input stream to read from
aByteOrder - the byte order
Method Detail

getByteOrder

public ByteOrder getByteOrder()

read

public int read(byte[] aBytes)
         throws IOException
TODO

Overrides:
read in class FilterInputStream
Throws:
IOException

readASCII

public String readASCII(int aLength)
                 throws IOException
Read string coded in ACSII

Parameters:
aLength - length to read
Returns:
the string readed
Throws:
IOException - if error occurs

readBoolean

public boolean readBoolean()
                    throws IOException
Reads one byte and returns true if that byte is nonzero, false if that byte is zero.

Returns:
the boolean value readed.
Throws:
IOException

readByte

public byte readByte()
              throws IOException
Read one byte

Returns:
the readed byte
Throws:
IOException

readComplexDouble

public final void readComplexDouble(double[] freal,
                                    double[] fimaginary,
                                    int len)
                             throws IOException

Read interleaved complex floating point 64 bit value pairs into real and imaginary arrays.

Parameters:
freal - an array of sufficient size in which to return the real values read, may be null if don't want real values
fimaginary - an array of sufficient size in which to return the real values read, may be null if don't want imaginary values
len - the number of 64 bit values to read
Throws:
IOException

readComplexFloat

public final void readComplexFloat(float[] freal,
                                   float[] fimaginary,
                                   int len)
                            throws IOException

Read interleaved complex floating point 32 bit value pairs into real and imaginary arrays.

Parameters:
freal - an array of sufficient size in which to return the real values read, may be null if don't want real values
fimaginary - an array of sufficient size in which to return the real values read, may be null if don't want imaginary values
len - the number of 32 bit values to read
Throws:
IOException

readDouble

public final double readDouble()
                        throws IOException

Read one floating point 64 bit value.

Returns:
a double value
Throws:
IOException

readDouble

public final void readDouble(double[] f,
                             int len)
                      throws IOException

Read an array of floating point 64 bit values.

Parameters:
f - an array of sufficient size in which to return the values read
len - the number of 64 bit values to read
Throws:
IOException

readFloat

public final float readFloat()
                      throws IOException

Read one floating point 32 bit value.

Returns:
a float value
Throws:
IOException

readFloat

public final void readFloat(float[] f,
                            int len)
                     throws IOException

Read an array of floating point 32 bit values.

Parameters:
f - an array of sufficient size in which to return the values read
len - the number of 32 bit values to read
Throws:
IOException

readFully

public void readFully(byte[] arg0)
               throws IOException
Throws:
IOException

readFully

public void readFully(byte[] arg0,
                      int arg1,
                      int arg2)
               throws IOException
Throws:
IOException

readInsistently

public void readInsistently(byte[] b,
                            int offset,
                            int length)
                     throws IOException

Read as many bytes as requested, unless an exception occurs.

Parameters:
b - buffer to read into
offset - offset (from 0) in buffer to read into
length - number of bytes to read (no more and no less)
Throws:
IOException

readSigned16

public final int readSigned16()
                       throws IOException

Read one signed integer 16 bit value.

Returns:
an int containing an unsigned value
Throws:
IOException

readSigned32

public final int readSigned32()
                       throws IOException

Read one signed integer 32 bit value.

Returns:
an int containing an signed value
Throws:
IOException

readString

public String readString(int aLength,
                         String aCharsetName)
                  throws IOException
read string coded in a specific charset

Parameters:
aLength - length to read
aCharsetName - the charset to use
Returns:
the string readed
Throws:
IOException - if error occurs

readUnsigned16

public final int readUnsigned16()
                         throws IOException

Read one unsigned integer 16 bit value.

Returns:
an int containing an unsigned value
Throws:
IOException

readUnsigned16

public final void readUnsigned16(short[] w,
                                 int len)
                          throws IOException

Read an array of unsigned integer 16 bit values.

Parameters:
w - an array of sufficient size in which to return the values read
len - the number of 16 bit values to read
Throws:
IOException

readUnsigned16

public final void readUnsigned16(short[] w,
                                 int offset,
                                 int len)
                          throws IOException

Read an array of unsigned integer 16 bit values.

Parameters:
w - an array of sufficient size in which to return the values read
offset - the offset in the array at which to begin storing values
len - the number of 16 bit values to read
Throws:
IOException

readUnsigned32

public final long readUnsigned32()
                          throws IOException

Read one unsigned integer 32 bit value.

Returns:
a long containing an unsigned value
Throws:
IOException

readUnsigned8

public final int readUnsigned8()
                        throws IOException

Read one unsigned integer 8 bit value.

Returns:
an int containing an unsigned value
Throws:
IOException

readUnsignedByte

public int readUnsignedByte()
                     throws IOException
Throws:
IOException

readUnsignedShort

public int readUnsignedShort()
                      throws IOException
Throws:
IOException

setByteOrder

public void setByteOrder(ByteOrder aByteOrder)

skip

public long skip(long aNumberToSkip)
          throws IOException
Skips over and discards n bytes of data from the input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.

Overrides:
skip in class FilterInputStream
Parameters:
aNumberToSkip - number of bytes to skip
Returns:
the actual number of bytes skipped.
Throws:
IOException


Copyright © 2009 dicom4j. All Rights Reserved.