com.tivoli.twg.engine
Class TWGByteArrayInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended bycom.tivoli.twg.libs.ByteArrayInputStr
          extended bycom.tivoli.twg.engine.TWGByteArrayInputStream

public class TWGByteArrayInputStream
extends ByteArrayInputStr

Director engine utility to create an input stream in which the bytes read are supplied by the contents of a byte array.


Field Summary
 
Fields inherited from class com.tivoli.twg.libs.ByteArrayInputStr
buf, count, mark, pos
 
Constructor Summary
TWGByteArrayInputStream(byte[] buffer)
          Creates a new byte array input stream that reads data from the specified byte array.
TWGByteArrayInputStream(byte[] buffer, int offset, int length)
          Creates a new byte array input stream that reads data from the specified byte array.
 
Method Summary
 boolean readBoolean()
          Reads a boolean.
 double readDouble()
          Reads a signed 64-bit long then converts it to a double using the longBitsToDouble method of class Double.
 double[] readDoubleArray()
          Reads an array of doubles.
 float readFloat()
          Reads a signed 32-bit integer then converts it to a float using the intBitsToFloat method of class Float.
 float[] readFloatArray()
          Reads an array of floats.
 int readInt()
          Reads a signed 32-bit integer.
 int[] readIntArray()
          Reads an array of signed 32-bit integers.
 long readLong()
          Reads a signed 64-bit integer.
 long[] readLongArray()
          Reads an array of signed 64-bit integers.
 short readShort()
          Reads a signed 16-bit integer.
 java.lang.String readUTF()
          Reads in a string encoded using a modified UTF-8 format.
 
Methods inherited from class com.tivoli.twg.libs.ByteArrayInputStr
available, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.io.InputStream
close, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TWGByteArrayInputStream

public TWGByteArrayInputStream(byte[] buffer)
Creates a new byte array input stream that reads data from the specified byte array.

Parameters:
buffer - input buffer.

TWGByteArrayInputStream

public TWGByteArrayInputStream(byte[] buffer,
                               int offset,
                               int length)
Creates a new byte array input stream that reads data from the specified byte array.

Parameters:
buffer - input buffer.
offset - offset in the buffer of the first byte to read.
length - maximum number of bytes to read from the buffer.
Method Detail

readBoolean

public boolean readBoolean()
Reads a boolean. This method reads a single byte. A value of 0 represents false; any other value represents true.

Returns:
next byte, interpreted as a boolean.

readDouble

public double readDouble()
Reads a signed 64-bit long then converts it to a double using the longBitsToDouble method of class Double.

Returns:
next eight bytes, interpreted as a double.

readDoubleArray

public double[] readDoubleArray()
Reads an array of doubles.

Returns:
next n bytes, interpreted as an array of double.

readFloat

public float readFloat()
Reads a signed 32-bit integer then converts it to a float using the intBitsToFloat method of class Float.

Returns:
next four bytes, interpreted as a float.

readFloatArray

public float[] readFloatArray()
Reads an array of floats.

Returns:
next n bytes, interpreted as an array of float.

readInt

public int readInt()
Reads a signed 32-bit integer.

Returns:
next four bytes, interpreted as an int.

readIntArray

public int[] readIntArray()
Reads an array of signed 32-bit integers.

Returns:
next n bytes, interpreted as an array of int.

readLong

public long readLong()
Reads a signed 64-bit integer.

Returns:
next eight bytes, interpreted as a long.

readLongArray

public long[] readLongArray()
Reads an array of signed 64-bit integers.

Returns:
next n bytes, interpreted as an array of long.

readShort

public short readShort()
Reads a signed 16-bit integer.

Returns:
next two bytes, interpreted as a short.

readUTF

public java.lang.String readUTF()
                         throws java.io.UTFDataFormatException
Reads in a string encoded using a modified UTF-8 format. The first two bytes are read as if by readShort. This value gives the number of following bytes that are in the encoded string, not the length of the resulting string. The following bytes are then interpreted as bytes encoding characters in the UTF-8 format and are converted into characters.

Returns:
Unicode string.
Throws:
java.io.UTFDataFormatException - thrown when the bytes do not represent a valid UTF-8 encoding of a Unicode string.