galaxy.io
Class XdrInBuffer

java.lang.Object
  |
  +--galaxy.io.XdrInBuffer

public class XdrInBuffer
extends java.lang.Object

This class reads data from a XDR-encoded byte array or input stream.


Field Summary
static int FALSE
          Integer value of "false".
static int TRUE
          Integer value of "true".
 
Constructor Summary
XdrInBuffer(byte[] bytes)
          Creates a XDR input buffer based on a specified byte array.
XdrInBuffer(java.io.DataInputStream inStream)
          Creates a XDR input buffer based on a specified input stream.
 
Method Summary
 int readBoolean()
          Reads a boolean value from the input buffer.
 byte[] readBytes(int length)
          Reads an array of bytes from the buffer.
 double readDouble()
          Reads a 64-bit floating point value from the input buffer.
 double[] readDoubleArray(int length)
          Reads an array of 64-bit floating point numbers from the buffer.
 int readEnumeration()
          Reads an enumerated type value from the input buffer.
 void readFixedLengthOpaqueData(byte[] bytes)
          Reads an array of bytes from the input buffer.
 float readFloat()
          Reads a 32-bit floating point value from the input buffer.
 float[] readFloatArray(int length)
          Reads an array of 32-bit floating point numbers from the buffer.
 int readInteger()
          Reads a 32-bit signed integer value from the input buffer.
 int[] readIntegerArray(int length)
          Reads an array of 32-bit integers from the buffer.
 long readLong()
          Reads a 64-bit signed integer value from the input buffer.
 long[] readLongArray(int length)
          Reads an array of 64-bit integers from the buffer.
 short[] readShortArray(int length)
          Reads an array of 16-bit integers from the buffer.
 java.lang.String readString()
          Reads a string value from the input buffer.
 byte[] readVariableLengthOpaqueData()
          Reads an array of bytes from the input buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FALSE

public static final int FALSE
Integer value of "false".

TRUE

public static final int TRUE
Integer value of "true".
Constructor Detail

XdrInBuffer

public XdrInBuffer(byte[] bytes)
Creates a XDR input buffer based on a specified byte array.
Parameters:
bytes - the buffer's data

XdrInBuffer

public XdrInBuffer(java.io.DataInputStream inStream)
Creates a XDR input buffer based on a specified input stream.
Parameters:
inStream - the input stream
Method Detail

readInteger

public int readInteger()
                throws java.io.IOException
Reads a 32-bit signed integer value from the input buffer.
Returns:
the integer value
Throws:
java.io.IOException - if an I/O error occurs

readEnumeration

public int readEnumeration()
                    throws java.io.IOException
Reads an enumerated type value from the input buffer.
Returns:
the enumerated type value
Throws:
java.io.IOException - if an I/O error occurs

readBoolean

public int readBoolean()
                throws java.io.IOException
Reads a boolean value from the input buffer.
Returns:
the boolean value (0 = false, 1 = true)
Throws:
java.io.IOException - if an I/O error occurs

readLong

public long readLong()
              throws java.io.IOException
Reads a 64-bit signed integer value from the input buffer.
Returns:
the integer value
Throws:
java.io.IOException - if an I/O error occurs

readFloat

public float readFloat()
                throws java.io.IOException
Reads a 32-bit floating point value from the input buffer.
Returns:
the floating point value
Throws:
java.io.IOException - if an I/O error occurs

readDouble

public double readDouble()
                  throws java.io.IOException
Reads a 64-bit floating point value from the input buffer.
Returns:
the floating point value
Throws:
java.io.IOException - if an I/O error occurs

readFixedLengthOpaqueData

public void readFixedLengthOpaqueData(byte[] bytes)
                               throws java.io.IOException
Reads an array of bytes from the input buffer. The number of bytes read is the same as the length of the bytes argument.
Parameters:
bytes - the array that the bytes will be read into
Throws:
java.io.IOException - if an I/O error occurs

readVariableLengthOpaqueData

public byte[] readVariableLengthOpaqueData()
                                    throws java.io.IOException
Reads an array of bytes from the input buffer. The number of bytes read is given by the first four bytes read off the input buffer (see XdrOutBuffer.writeVariableLengthOpaqueData). Note that return value does not include any padding bytes (if they were present).
Returns:
the byte array
Throws:
java.io.IOException - if an I/O error occurs

readString

public java.lang.String readString()
                            throws java.io.UnsupportedEncodingException,
                                   java.io.IOException
Reads a string value from the input buffer.
Returns:
the string
Throws:
java.io.UnsupportedEncodingException - if the string encoding format (ISO-8859-1) is not available on the local platform
java.io.IOException - if an I/O error occurs

readShortArray

public short[] readShortArray(int length)
                       throws java.io.IOException
Reads an array of 16-bit integers from the buffer. Note that the XDR encoding only directly supports 32- and 64-bit integers, so 32-bit integers are actually read from the buffer and cast into 16-bit integers. This is fine as long as 32-bits read do indeed only contain 16-bit values.
Parameters:
length - the size of the array to read
Returns:
the array

readIntegerArray

public int[] readIntegerArray(int length)
                       throws java.io.IOException
Reads an array of 32-bit integers from the buffer.
Parameters:
length - the size of the array to read
Returns:
the array

readLongArray

public long[] readLongArray(int length)
                     throws java.io.IOException
Reads an array of 64-bit integers from the buffer.
Parameters:
length - the size of the array to read
Returns:
the array

readFloatArray

public float[] readFloatArray(int length)
                       throws java.io.IOException
Reads an array of 32-bit floating point numbers from the buffer.
Parameters:
length - the size of the array to read
Returns:
the array

readDoubleArray

public double[] readDoubleArray(int length)
                         throws java.io.IOException
Reads an array of 64-bit floating point numbers from the buffer.
Parameters:
length - the size of the array to read
Returns:
the array

readBytes

public byte[] readBytes(int length)
                 throws java.io.IOException
Reads an array of bytes from the buffer.
Parameters:
length - the number of bytes to read
Returns:
array of bytes read