Class ObjectBuffer

java.lang.Object
  extended by ObjectBuffer

public class ObjectBuffer
extends java.lang.Object

A wraper class to java.nio.ByteBuffer for handling objects. The internal ByteBuffer is used for storing and retrieving objects. The ByteBuffer may be direct or a heap buffer. There are no bulk get / put methods since an object array can also be get / put as single object.

Author:
Heinz Kredel.

Field Summary
private  java.nio.ByteBuffer bb
           
 
Constructor Summary
ObjectBuffer(java.nio.ByteBuffer bb)
          Wrap an existing ByteBuffer as Object Buffer.
 
Method Summary
 java.lang.Object get()
          Get and remove the next Object form the ByteBuffer.
 void put(java.lang.Object obj)
          Put an Object to the ByteBuffer.
 java.lang.String toString()
          to String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bb

private java.nio.ByteBuffer bb
Constructor Detail

ObjectBuffer

public ObjectBuffer(java.nio.ByteBuffer bb)
Wrap an existing ByteBuffer as Object Buffer.

Method Detail

get

public java.lang.Object get()
                     throws java.io.IOException,
                            java.lang.ClassNotFoundException
Get and remove the next Object form the ByteBuffer. If only a partial object remains in the buffer an BufferUnderFlowException is thrown.

Returns:
the next object from the buffer.
Throws:
java.io.IOException
java.lang.ClassNotFoundException

put

public void put(java.lang.Object obj)
         throws java.io.IOException
Put an Object to the ByteBuffer. If the object does not fit into the buffer a BufferOverflowException is thrown.

Parameters:
obj - the object to be put into the buffer.
Throws:
java.io.IOException

toString

public java.lang.String toString()
to String

Overrides:
toString in class java.lang.Object