net.sf.transjvm.jvm
Class ByteStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.ByteArrayOutputStream
          extended by net.sf.transjvm.jvm.ByteStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class ByteStream
extends java.io.ByteArrayOutputStream

An augmented ByteArrayOutputStream


Field Summary
 
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
 
Constructor Summary
ByteStream(int capacity)
          Constructor for the ByteStream object
 
Method Summary
 void writeByteByte(int value1, int value2)
          Writes two bytes consecutively.
 void writeByteInt(int byteValue, int intValue)
          Writes a byte followed by an int.
 void writeByteShort(int byteValue, int shortValue)
          Writes a byte followed by a short.
 void writeByteShortShort(int byteValue, int shortValue1, int shortValue2)
          Writes a byte followed by two consecutive shorts
 void writeInt(int value)
          Writes an int.
 void writeIntAt(int mark, int value)
          Writes an int to the stream at given mark.
 void writeShort(int value)
          Writes a short.
 void writeShortAt(int mark, int value)
          Writes an int to the stream at given mark.
 void writeTo(byte[] array, int offset)
          Writes the contents of this stream to a byte array.
 void writeUTF(java.lang.String s)
          Writes String s to this stream in Java UTF8 format.
 
Methods inherited from class java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, write, write, writeTo
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ByteStream

public ByteStream(int capacity)
Constructor for the ByteStream object

Parameters:
capacity - Initial capacity of this ByteStream.
Method Detail

writeByteByte

public void writeByteByte(int value1,
                          int value2)
Writes two bytes consecutively.

Parameters:
value1 - First byte to be written.
value2 - Secind byte to be written

writeByteShort

public void writeByteShort(int byteValue,
                           int shortValue)
Writes a byte followed by a short.

Parameters:
byteValue - The byte to be written
shortValue - The short to be written

writeByteShortShort

public void writeByteShortShort(int byteValue,
                                int shortValue1,
                                int shortValue2)
Writes a byte followed by two consecutive shorts

Parameters:
byteValue - The byte to be written
shortValue1 - The first short to be written
shortValue2 - The second short to be written

writeByteInt

public void writeByteInt(int byteValue,
                         int intValue)
Writes a byte followed by an int.

Parameters:
byteValue - The byte to be written
intValue - The int to be written

writeShort

public void writeShort(int value)
Writes a short.

Parameters:
value - The short to be written

writeInt

public void writeInt(int value)
Writes an int.

Parameters:
value - The int to be written

writeIntAt

public void writeIntAt(int mark,
                       int value)
Writes an int to the stream at given mark. This method is designed for backpatching, so that a place can be reserved for a value, which is then written later.

Parameters:
mark - Place at which to write.
value - Value to write.
Throws:
java.lang.IllegalArgumentException - if mark + 4 > size().

writeShortAt

public void writeShortAt(int mark,
                         int value)
Writes an int to the stream at given mark. This method is designed for backpatching, so that a place can be reserved for a value, which is then written later.

Parameters:
mark - Place at which to write.
value - Value to write.
Throws:
java.lang.IllegalArgumentException - if mark + 2 > size().

writeTo

public void writeTo(byte[] array,
                    int offset)
Writes the contents of this stream to a byte array.

Parameters:
array - The array to write to.
offset - Offset from start of array to write to.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if size() + offset > array.length

writeUTF

public void writeUTF(java.lang.String s)
Writes String s to this stream in Java UTF8 format.

Parameters:
s - String to be written.


Copyright 2004-5, Mark Shannon