Class OutputBuffer

java.lang.Object
com.arjuna.ats.arjuna.state.OutputBuffer
Direct Known Subclasses:
OutputObjectState

public class OutputBuffer extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected static final int
     
    protected static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create 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.
    Create a new OutputBuffer and initialise its state with a copy of the provided buffer.
  • Method Summary

    Modifier and Type
    Method
    Description
    final byte[]
    Return the byte array used to store data types.
    void
    Copy the provided OutputBuffer and overwrite the current instance.
    final int
    Return the length of the byte array being used to store data types.
    final void
    packBoolean(boolean b)
    Pack the boolean.
    final void
    packByte(byte b)
    Pack a byte.
    final void
    packBytes(byte[] b)
    Pack the array of bytes.
    final void
    packChar(char c)
    Pack the character.
    final void
    packDouble(double d)
    Pack the double.
    final void
    packFloat(float f)
    Pack the float.
    final void
    packInt(int i)
    Pack the integer.
    void
    Pack this buffer into that provided.
    final void
    packLong(long l)
    Pack the long.
    final void
    packShort(short s)
    Pack the short.
    final void
    Pack the String.
    final void
    packStringBytes(byte[] bytes)
     
    void
    Print out information about this instance.
    final void
    Clear the OutputBuffer and rewind the pack pointer.
    final boolean
    Reset the pack pointer.
    final boolean
    Is the buffer valid?

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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

      public OutputBuffer(OutputBuffer copyFrom)
      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

      public void copy(OutputBuffer b)
      Copy the provided OutputBuffer and overwrite the current instance.
    • reset

      public final void reset() throws IOException
      Clear the OutputBuffer and rewind the pack pointer.
      Throws:
      IOException
    • packByte

      public final void packByte(byte b) throws IOException
      Pack a byte. If the buffer is invalid then an IOException is thrown.
      Throws:
      IOException
    • packBytes

      public final void packBytes(byte[] b) throws IOException
      Pack the array of bytes. If the buffer is invalid then an IOException is thrown.
      Throws:
      IOException
    • packBoolean

      public final void packBoolean(boolean b) throws IOException
      Pack the boolean. If the buffer is invalid then an IOException is thrown.
      Throws:
      IOException
    • packChar

      public final void packChar(char c) throws IOException
      Pack the character. If the buffer is invalid then an IOException is thrown.
      Throws:
      IOException
    • packShort

      public final void packShort(short s) throws IOException
      Pack the short. If the buffer is invalid then an IOException is thrown.
      Throws:
      IOException
    • packInt

      public final void packInt(int i) throws IOException
      Pack the integer. If the buffer is invalid then an IOException is thrown.
      Throws:
      IOException
    • packLong

      public final void packLong(long l) throws IOException
      Pack the long. If the buffer is invalid then an IOException is thrown.
      Throws:
      IOException
    • packFloat

      public final void packFloat(float f) throws IOException
      Pack the float. If the buffer is invalid then an IOException is thrown.
      Throws:
      IOException
    • packDouble

      public final void packDouble(double d) throws IOException
      Pack the double. If the buffer is invalid then an IOException is thrown.
      Throws:
      IOException
    • packString

      public final void packString(String s) throws IOException
      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

      public final void packStringBytes(byte[] bytes) throws IOException
      Throws:
      IOException
    • packInto

      public void packInto(OutputBuffer buff) throws IOException
      Pack this buffer into that provided. If the buffer is invalid then an IOException is thrown.
      Throws:
      IOException
    • print

      public void print(PrintWriter strm)
      Print out information about this instance.
    • rewrite

      public final boolean rewrite()
      Reset the pack pointer.