jpl.mipl.io.vicar
Class VicarDataInputDIWrapper

java.lang.Object
  extended by java.io.InputStream
      extended by jpl.mipl.io.vicar.VicarDataInputDIWrapper
All Implemented Interfaces:
Closeable, DataInput
Direct Known Subclasses:
VicarSwapDataInputDIWrapper, VicarVaxDataInputDIWrapper

public class VicarDataInputDIWrapper
extends InputStream
implements DataInput

VicarDataInputDIWrapper lets an application read primitive data types from a DataInput object; the data are converted (if necessary) from the int and real formats specified in the VicarDataFormat object that is passed in via the constructor.

This is exactly like VicarDataInputStream except the thing being wrapped is a DataInput instead of a InputStream.

See Also:
VicarDataInputStream

Field Summary
protected  long[] _ieeeDouble
           
protected  int[] _ieeeFloat
           
protected  int _intFmtCode
           
protected  long[] _rawDouble
           
protected  int[] _rawFloat
           
protected  int _realFmtCode
           
protected  long[] _vaxDouble
           
protected  int[] _vaxFloat
           
 
Constructor Summary
VicarDataInputDIWrapper(DataInput di_in, int intFmtCode, int realFmtCode)
          Creates a new VicarDataInputDIWrapper to read data from the specified DataInput object.
 
Method Summary
 int read()
          Reads the next byte of data from this input stream.
 boolean readBoolean()
          Reads a boolean from this data input stream.
 byte readByte()
          Reads a signed 8-bit value from this data input stream.
 char readChar()
          Reads a Unicode character from this data input stream.
 double readDouble()
          Reads a double from this data input stream.
 float readFloat()
          Reads a float from this data input stream.
 void readFully(byte[] b)
          Reads b.length bytes from this data input stream into the byte array.
 void readFully(byte[] b, int off, int len)
          Reads exactly len bytes from this data input stream into the byte array.
 int readInt()
          Reads a signed 32-bit integer from this input stream.
 String readLine()
          Deprecated. This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form
    DataInputStream d = new DataInputStream(in);
with
    BufferedReader d = new BufferedReader(new InputStreamReader(in));
 long readLong()
          Reads a signed 64-bit integer from this data input stream.
 short readShort()
          Reads a signed 16-bit number from this data input stream.
 int readUnsignedByte()
          Reads an unsigned 8-bit number from this data input stream.
 int readUnsignedShort()
          Reads an unsigned 16-bit number from this data input stream.
 String readUTF()
          Reads in a string that has been encoded using a modified UTF-8 format from this data input stream.
protected  long[] shift_right_3(long[] y, long[] x)
           
protected  int[] shift_right(int[] x)
           
 int skipBytes(int n)
          Skips exactly n bytes of input in the underlying input stream.
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_intFmtCode

protected int _intFmtCode

_realFmtCode

protected int _realFmtCode

_rawFloat

protected int[] _rawFloat

_vaxFloat

protected int[] _vaxFloat

_ieeeFloat

protected int[] _ieeeFloat

_rawDouble

protected long[] _rawDouble

_vaxDouble

protected long[] _vaxDouble

_ieeeDouble

protected long[] _ieeeDouble
Constructor Detail

VicarDataInputDIWrapper

public VicarDataInputDIWrapper(DataInput di_in,
                               int intFmtCode,
                               int realFmtCode)
Creates a new VicarDataInputDIWrapper to read data from the specified DataInput object.

Parameters:
in - the input stream you`re wrapping
format - the data format to convert *from*
Method Detail

readShort

public short readShort()
                throws IOException
Reads a signed 16-bit number from this data input stream. The method reads two bytes from the underlying input stream.

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readShort in interface DataInput
Returns:
the next two bytes of this input stream, interpreted as a signed 16-bit number.
Throws:
EOFException - if this input stream reaches the end before reading two bytes.
IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

readUnsignedShort

public int readUnsignedShort()
                      throws IOException
Reads an unsigned 16-bit number from this data input stream. This method reads two bytes from the underlying input stream.

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readUnsignedShort in interface DataInput
Returns:
the next two bytes of this input stream, interpreted as an unsigned 16-bit integer.
Throws:
EOFException - if this input stream reaches the end before reading two bytes.
IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

readInt

public int readInt()
            throws IOException
Reads a signed 32-bit integer from this input stream. This method reads four bytes from the underlying input stream.

This method blocks until the four bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readInt in interface DataInput
Returns:
the next four bytes of this input stream, interpreted as an int.
Throws:
EOFException - if this input stream reaches the end before reading four bytes.
IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

readLong

public long readLong()
              throws IOException
Reads a signed 64-bit integer from this data input stream. This method reads eight bytes from the underlying input stream.

This method blocks until the eight bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readLong in interface DataInput
Returns:
the next eight bytes of this input stream, interpreted as a long.
Throws:
EOFException - if this input stream reaches the end before reading eight bytes.
IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

readFloat

public float readFloat()
                throws IOException
Reads a float from this data input stream. This method reads an int value as if by the readInt method and then converts that int to a float using the intBitsToFloat method in class Float. This method blocks until the four bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readFloat in interface DataInput
Returns:
the next four bytes of this input stream, interpreted as a float.
Throws:
EOFException - if this input stream reaches the end before reading four bytes.
IOException - if an I/O error occurs.
See Also:
DataInputStream.readInt(), Float.intBitsToFloat(int)

shift_right

protected int[] shift_right(int[] x)

shift_right_3

protected long[] shift_right_3(long[] y,
                               long[] x)

readDouble

public double readDouble()
                  throws IOException
Reads a double from this data input stream. This method reads a long value as if by the readLong method and then converts that long to a double using the longBitsToDouble method in class Double.

This method blocks until the eight bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readDouble in interface DataInput
Returns:
the next eight bytes of this input stream, interpreted as a double.
Throws:
EOFException - if this input stream reaches the end before reading eight bytes.
IOException - if an I/O error occurs.
See Also:
DataInputStream.readLong(), Double.longBitsToDouble(long)

readFully

public final void readFully(byte[] b)
                     throws IOException
Reads b.length bytes from this data input stream into the byte array. This method reads repeatedly from the underlying stream until all the bytes are read. This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readFully in interface DataInput
Parameters:
b - the buffer into which the data is read.
Throws:
EOFException - if this input stream reaches the end before reading all the bytes.
IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

readFully

public final void readFully(byte[] b,
                            int off,
                            int len)
                     throws IOException
Reads exactly len bytes from this data input stream into the byte array. This method reads repeatedly from the underlying stream until all the bytes are read. This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readFully in interface DataInput
Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the number of bytes to read.
Throws:
EOFException - if this input stream reaches the end before reading all the bytes.
IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

skipBytes

public final int skipBytes(int n)
                    throws IOException
Skips exactly n bytes of input in the underlying input stream. This method blocks until all the bytes are skipped, the end of the stream is detected, or an exception is thrown.

Specified by:
skipBytes in interface DataInput
Parameters:
n - the number of bytes to be skipped.
Returns:
the number of bytes skipped, which is always n.
Throws:
EOFException - if this input stream reaches the end before skipping all the bytes.
IOException - if an I/O error occurs.

read

public int read()
         throws IOException
Reads the next byte of data from this input stream.

Specified by:
read in class InputStream
Throws:
IOException - if the DataInput does
See Also:
InputStream.read()

readBoolean

public final boolean readBoolean()
                          throws IOException
Reads a boolean from this data input stream. This method reads a single byte from the underlying input stream. A value of 0 represents false. Any other value represents true. This method blocks until either the byte is read, the end of the stream is detected, or an exception is thrown.

Specified by:
readBoolean in interface DataInput
Returns:
the boolean value read.
Throws:
EOFException - if this input stream has reached the end.
IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

readByte

public final byte readByte()
                    throws IOException
Reads a signed 8-bit value from this data input stream. This method reads a byte from the underlying input stream. If the byte read is b, where 0 <= b <= 255, then the result is:

This method blocks until either the byte is read, the end of the stream is detected, or an exception is thrown.

Specified by:
readByte in interface DataInput
Returns:
the next byte of this input stream as a signed 8-bit byte.
Throws:
EOFException - if this input stream has reached the end.
IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

readUnsignedByte

public final int readUnsignedByte()
                           throws IOException
Reads an unsigned 8-bit number from this data input stream. This method reads a byte from this data input stream's underlying input stream and returns that byte. This method blocks until the byte is read, the end of the stream is detected, or an exception is thrown.

Specified by:
readUnsignedByte in interface DataInput
Returns:
the next byte of this input stream, interpreted as an unsigned 8-bit number.
Throws:
EOFException - if this input stream has reached the end.
IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

readChar

public final char readChar()
                    throws IOException
Reads a Unicode character from this data input stream. This method reads two bytes from the underlying input stream. If the bytes read, in order, are b1 and b2, where 0 <= b1, b1 <= 255, then the result is equal to:

This method blocks until either the two bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readChar in interface DataInput
Returns:
the next two bytes of this input stream as a Unicode character.
Throws:
EOFException - if this input stream reaches the end before reading two bytes.
IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

readLine

public final String readLine()
                      throws IOException
Deprecated. This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form
    DataInputStream d = new DataInputStream(in);
with
    BufferedReader d = new BufferedReader(new InputStreamReader(in));

Reads the next line of text from this data input stream. This method successively reads bytes from the underlying input stream until it reaches the end of a line of text.

A line of text is terminated by a carriage return character ('\r'), a newline character ('\n'), a carriage return character immediately followed by a newline character, or the end of the input stream. The line-terminating character(s), if any, are not returned as part of the string that is returned.

This method blocks until a newline character is read, a carriage return and the byte following it are read (to see if it is a newline), the end of the stream is detected, or an exception is thrown.

Specified by:
readLine in interface DataInput
Returns:
the next line of text from this input stream, or null if no bytes are read before end-of-file is reached.
Throws:
IOException - if an I/O error occurs.
See Also:
BufferedReader.readLine(), FilterInputStream.in

readUTF

public final String readUTF()
                     throws IOException
Reads in a string that has been encoded using a modified UTF-8 format from this data input stream. This method calls readUTF(this). See readUTF(java.io.DataInput) for a more complete description of the format.

This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.

Specified by:
readUTF in interface DataInput
Returns:
a Unicode string.
Throws:
EOFException - if this input stream reaches the end before reading all the bytes.
IOException - if an I/O error occurs.
See Also:
DataInputStream.readUTF(java.io.DataInput)