com.arjuna.ats.arjuna.state
Class InputBuffer

java.lang.Object
  extended bycom.arjuna.ats.arjuna.state.InputBuffer
Direct Known Subclasses:
InputObjectState

public class InputBuffer
extends java.lang.Object

An InputBuffer is used to retrieve various Java types from a byte stream created using an OutputBuffer. Similar to java serialization. However, InputBuffers are compatible with OTSArjuna states.

Since:
JTS 1.0.
Version:
$Id: InputBuffer.java 2342 2006-03-30 13:06:17Z $
Author:
Mark Little (mark@arjuna.com)

Field Summary
protected  boolean _valid
           
 
Constructor Summary
InputBuffer()
          Create a new buffer.
InputBuffer(byte[] b)
          Create our own copy of the byte array.
InputBuffer(InputBuffer buff)
          Create a new buffer and copy the provided one.
 
Method Summary
 byte[] buffer()
          Return the internal byte buffer.
 void copy(InputBuffer buff)
          Copy the existing buffer.
 int length()
          Return the length of the byte buffer.
 void print(java.io.PrintWriter strm)
          Print information about this instance.
 boolean reread()
          Reset the read pointer for this buffer.
 void setBuffer(byte[] b)
          Set the buffer to be used by this instance.
 boolean unpackBoolean()
          Unpack a boolean from the stream.
 byte unpackByte()
          Unpack a byte from the stream.
 byte[] unpackBytes()
          Unpack the next byte array from the stream.
 char unpackChar()
          Unpack a character from the stream.
 double unpackDouble()
          Unpack a double from the stream.
 float unpackFloat()
          Unpack a float from the stream.
 void unpackFrom(InputBuffer buff)
          Unpack a buffer from the provided buffer, and initialise this instance with it.
 int unpackInt()
          Unpack an integer from the stream.
 long unpackLong()
          Unpack a long from the stream.
 short unpackShort()
          Unpack a short from the stream.
 java.lang.String unpackString()
          Unpack a String from the stream.
 boolean valid()
          Is the buffer valid?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_valid

protected boolean _valid
Constructor Detail

InputBuffer

public InputBuffer()
Create a new buffer.


InputBuffer

public InputBuffer(byte[] b)
Create our own copy of the byte array.


InputBuffer

public InputBuffer(InputBuffer buff)
Create a new buffer and copy the provided one.

Method Detail

valid

public final boolean valid()
Is the buffer valid?


copy

public void copy(InputBuffer buff)
Copy the existing buffer.


length

public final int length()
Return the length of the byte buffer.


buffer

public final byte[] buffer()
Return the internal byte buffer.


setBuffer

public final void setBuffer(byte[] b)
Set the buffer to be used by this instance.


unpackByte

public final byte unpackByte()
                      throws java.io.IOException
Unpack a byte from the stream. If the next item in the buffer is not of the right type then an IOException is thrown.

Throws:
java.io.IOException

unpackBytes

public final byte[] unpackBytes()
                         throws java.io.IOException
Unpack the next byte array from the stream. If the next item in the buffer is not of the right type then an IOException is thrown.

Throws:
java.io.IOException

unpackBoolean

public final boolean unpackBoolean()
                            throws java.io.IOException
Unpack a boolean from the stream. If the next item in the buffer is not of the right type then an IOException is thrown.

Throws:
java.io.IOException

unpackChar

public final char unpackChar()
                      throws java.io.IOException
Unpack a character from the stream. If the next item in the buffer is not of the right type then an IOException is thrown.

Throws:
java.io.IOException

unpackShort

public final short unpackShort()
                        throws java.io.IOException
Unpack a short from the stream. If the next item in the buffer is not of the right type then an IOException is thrown.

Throws:
java.io.IOException

unpackInt

public final int unpackInt()
                    throws java.io.IOException
Unpack an integer from the stream. If the next item in the buffer is not of the right type then an IOException is thrown.

Throws:
java.io.IOException

unpackLong

public final long unpackLong()
                      throws java.io.IOException
Unpack a long from the stream. If the next item in the buffer is not of the right type then an IOException is thrown.

Throws:
java.io.IOException

unpackFloat

public final float unpackFloat()
                        throws java.io.IOException
Unpack a float from the stream. If the next item in the buffer is not of the right type then an IOException is thrown.

Throws:
java.io.IOException

unpackDouble

public final double unpackDouble()
                          throws java.io.IOException
Unpack a double from the stream. If the next item in the buffer is not of the right type then an IOException is thrown.

Throws:
java.io.IOException

unpackString

public final java.lang.String unpackString()
                                    throws java.io.IOException
Unpack a String from the stream. If the next item in the buffer is not of the right type then an IOException is thrown. Currently different from the C++ version in that a distinct new instance will always be returned, rather than a reference to a previously returned object in the case of the "same" string.

Throws:
java.io.IOException

unpackFrom

public void unpackFrom(InputBuffer buff)
                throws java.io.IOException
Unpack a buffer from the provided buffer, and initialise this instance with it. If the next item in the buffer is not of the right type then an IOException is thrown.

Throws:
java.io.IOException

reread

public final boolean reread()
Reset the read pointer for this buffer.


print

public void print(java.io.PrintWriter strm)
Print information about this instance.