Package com.arjuna.ats.arjuna.state
Class OutputBuffer
java.lang.Object
com.arjuna.ats.arjuna.state.OutputBuffer
- Direct Known Subclasses:
OutputObjectState
An OuptputBuffer is used to store various Java types as a byte stream.
Similar to java serialization. However, OutputBuffers are compatible with
OTSArjuna states.
- Since:
- JTS 1.0.
- Version:
- $Id: OutputBuffer.java 2342 2006-03-30 13:06:17Z $
- Author:
- Mark Little (mark@arjuna.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected static final intprotected static final int -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new buffer.OutputBuffer(byte[] b) Create a new buffer using the provided byte array.OutputBuffer(int buffSize) Create a new buffer with the specified initial size.OutputBuffer(OutputBuffer copyFrom) Create a new OutputBuffer and initialise its state with a copy of the provided buffer. -
Method Summary
Modifier and TypeMethodDescriptionfinal byte[]buffer()Return the byte array used to store data types.voidcopy(OutputBuffer b) Copy the provided OutputBuffer and overwrite the current instance.final intlength()Return the length of the byte array being used to store data types.final voidpackBoolean(boolean b) Pack the boolean.final voidpackByte(byte b) Pack a byte.final voidpackBytes(byte[] b) Pack the array of bytes.final voidpackChar(char c) Pack the character.final voidpackDouble(double d) Pack the double.final voidpackFloat(float f) Pack the float.final voidpackInt(int i) Pack the integer.voidpackInto(OutputBuffer buff) Pack this buffer into that provided.final voidpackLong(long l) Pack the long.final voidpackShort(short s) Pack the short.final voidpackString(String s) Pack the String.final voidpackStringBytes(byte[] bytes) voidprint(PrintWriter strm) Print out information about this instance.final voidreset()Clear the OutputBuffer and rewind the pack pointer.final booleanrewrite()Reset the pack pointer.final booleanvalid()Is the buffer valid?
-
Field Details
-
_valid
protected boolean _valid -
headerSize
protected static final int headerSize- See Also:
-
ALIGNMENT
protected static final int ALIGNMENT- See Also:
-
-
Constructor Details
-
OutputBuffer
public OutputBuffer()Create a new buffer. -
OutputBuffer
public OutputBuffer(int buffSize) Create a new buffer with the specified initial size. If required, the internal byte array will be automatically increased in size. -
OutputBuffer
public OutputBuffer(byte[] b) Create a new buffer using the provided byte array. -
OutputBuffer
Create a new OutputBuffer and initialise its state with a copy of the provided buffer.
-
-
Method Details
-
valid
public final boolean valid()Is the buffer valid? -
buffer
public final byte[] buffer()Return the byte array used to store data types. -
length
public final int length()Return the length of the byte array being used to store data types. -
copy
Copy the provided OutputBuffer and overwrite the current instance. -
reset
Clear the OutputBuffer and rewind the pack pointer.- Throws:
IOException
-
packByte
Pack a byte. If the buffer is invalid then an IOException is thrown.- Throws:
IOException
-
packBytes
Pack the array of bytes. If the buffer is invalid then an IOException is thrown.- Throws:
IOException
-
packBoolean
Pack the boolean. If the buffer is invalid then an IOException is thrown.- Throws:
IOException
-
packChar
Pack the character. If the buffer is invalid then an IOException is thrown.- Throws:
IOException
-
packShort
Pack the short. If the buffer is invalid then an IOException is thrown.- Throws:
IOException
-
packInt
Pack the integer. If the buffer is invalid then an IOException is thrown.- Throws:
IOException
-
packLong
Pack the long. If the buffer is invalid then an IOException is thrown.- Throws:
IOException
-
packFloat
Pack the float. If the buffer is invalid then an IOException is thrown.- Throws:
IOException
-
packDouble
Pack the double. If the buffer is invalid then an IOException is thrown.- Throws:
IOException
-
packString
Pack the String. Currently different from the C++ version in that a copy of the string will always be packed, even if we have previously seen this object. If the buffer is invalid then an IOException is thrown.- Throws:
IOException
-
packStringBytes
- Throws:
IOException
-
packInto
Pack this buffer into that provided. If the buffer is invalid then an IOException is thrown.- Throws:
IOException
-
print
Print out information about this instance. -
rewrite
public final boolean rewrite()Reset the pack pointer.
-