com.tivoli.twg.engine
Class TWGByteArrayOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended bycom.tivoli.twg.libs.ByteArrayOutputStr
          extended bycom.tivoli.twg.engine.TWGByteArrayOutputStream

public class TWGByteArrayOutputStream
extends ByteArrayOutputStr

Director engine utility that implements an output stream in which the data is written into a byte array. The buffer automatically grows as data is written to it. The data can be retrieved using toByteArray() and toString().


Field Summary
 
Fields inherited from class com.tivoli.twg.libs.ByteArrayOutputStr
buf, count
 
Constructor Summary
TWGByteArrayOutputStream()
          Creates a new byte array output stream.
TWGByteArrayOutputStream(int size)
          Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.
 
Method Summary
static int lengthUTF(java.lang.String value)
          lengthUTF
 void writeBoolean(boolean value)
          Writes a boolean as a 1-byte value.
 void writeDouble(double value)
          Writes a double using the doubleToLongBits method of of class Double as eight bytes, high byte first.
 void writeDouble(short length, double[] value)
          Writes an double array.
 void writeFloat(float value)
          Writes a float using the floatToIntBits method of of class Float as four bytes, high byte first.
 void writeFloat(short length, float[] value)
          Writes an float array.
 void writeInt(int value)
          Writes an int as four bytes, high byte first.
 void writeInt(short length, int[] value)
          Writes an int array.
 void writeLong(long value)
          Writes a long as eight bytes, high byte first.
 void writeLong(short length, long[] value)
          Writes a long array.
 void writeShort(short value)
          Writes an short as two bytes, high byte first.
 void writeUTF(java.lang.String value)
          Writes a string using UTF-8 encoding in a machine-independent manner.
 
Methods inherited from class com.tivoli.twg.libs.ByteArrayOutputStr
reset, size, toByteArray, toString, toString, toString, write, write, writeTo
 
Methods inherited from class java.io.OutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TWGByteArrayOutputStream

public TWGByteArrayOutputStream()
Creates a new byte array output stream.


TWGByteArrayOutputStream

public TWGByteArrayOutputStream(int size)
Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.

Parameters:
size - initial size.
Method Detail

lengthUTF

public static int lengthUTF(java.lang.String value)
lengthUTF


writeBoolean

public void writeBoolean(boolean value)
Writes a boolean as a 1-byte value. The value true is written out as the value 1; the value false is written out as the value 0.

Parameters:
value - boolean to be written.

writeDouble

public void writeDouble(double value)
Writes a double using the doubleToLongBits method of of class Double as eight bytes, high byte first.

Parameters:
value - double to be written.

writeDouble

public void writeDouble(short length,
                        double[] value)
Writes an double array. Two bytes are written as if by the writeShort method giving the number of elements to follow. Following this count, each double is output, high byte first.

Parameters:
length - number of array elements to be written.
value - double array to be written.

writeFloat

public void writeFloat(float value)
Writes a float using the floatToIntBits method of of class Float as four bytes, high byte first.

Parameters:
value - float to be written.

writeFloat

public void writeFloat(short length,
                       float[] value)
Writes an float array. Two bytes are written as if by the writeShort method giving the number of elements to follow. Following this count, each float is output, high byte first.

Parameters:
length - number of array elements to be written.
value - float array to be written.

writeInt

public void writeInt(int value)
Writes an int as four bytes, high byte first.

Parameters:
value - int to be written.

writeInt

public void writeInt(short length,
                     int[] value)
Writes an int array. Two bytes are written as if by the writeShort method giving the number of elements to follow. Following this count, each int is output, high byte first.

Parameters:
length - number of array elements to be written.
value - int array to be written.

writeLong

public void writeLong(long value)
Writes a long as eight bytes, high byte first.

Parameters:
value - long to be written.

writeLong

public void writeLong(short length,
                      long[] value)
Writes a long array. Two bytes are written as if by the writeShort method giving the number of elements to follow. Following this count, each long is output, high byte first.

Parameters:
length - number of array elements to be written.
value - long array to be written.

writeShort

public void writeShort(short value)
Writes an short as two bytes, high byte first.

Parameters:
value - short to be written.

writeUTF

public void writeUTF(java.lang.String value)
Writes a string using UTF-8 encoding in a machine-independent manner. Two bytes are written as if by the writeShort method giving the number of bytes to follow. This value is the number of bytes actually written out, not the length of the string. Following the length, each character of the string is output, in sequence, using the UTF-8 encoding for each character.

Parameters:
value - String to be written.