com.esotericsoftware.kryo
Class ObjectBuffer

java.lang.Object
  extended by com.esotericsoftware.kryo.ObjectBuffer

public class ObjectBuffer
extends java.lang.Object

Serializes objects to and from byte arrays and streams.

This class uses a buffer internally and is not thread safe.

Author:
Nathan Sweet

Constructor Summary
ObjectBuffer(Kryo kryo)
          Creates an ObjectStream with an initial buffer size of 2KB and a maximum size of 16KB.
ObjectBuffer(Kryo kryo, int maxCapacity)
           
ObjectBuffer(Kryo kryo, int initialCapacity, int maxCapacity)
           
 
Method Summary
 java.lang.Object readClassAndObject(byte[] objectBytes)
           
 java.lang.Object readClassAndObject(java.io.InputStream input)
          Reads to the end of the stream and returns the deserialized object.
 java.lang.Object readClassAndObject(java.io.InputStream input, int contentLength)
          Reads the specified number of bytes and returns the deserialized object.
<T> T
readObject(byte[] objectBytes, java.lang.Class<T> type)
           
<T> T
readObject(java.io.InputStream input, java.lang.Class<T> type)
          Reads to the end of the stream and returns the deserialized object.
<T> T
readObject(java.io.InputStream input, int contentLength, java.lang.Class<T> type)
          Reads the specified number of bytes and returns the deserialized object.
<T> T
readObjectData(byte[] objectBytes, java.lang.Class<T> type)
           
<T> T
readObjectData(java.io.InputStream input, java.lang.Class<T> type)
          Reads to the end of the stream and returns the deserialized object.
<T> T
readObjectData(java.io.InputStream input, int contentLength, java.lang.Class<T> type)
          Reads the specified number of bytes and returns the deserialized object.
 void setKryo(Kryo kryo)
           
 byte[] writeClassAndObject(java.lang.Object object)
           
 void writeClassAndObject(java.io.OutputStream output, java.lang.Object object)
           
 byte[] writeObject(java.lang.Object object)
           
 void writeObject(java.io.OutputStream output, java.lang.Object object)
           
 byte[] writeObjectData(java.lang.Object object)
           
 void writeObjectData(java.io.OutputStream output, java.lang.Object object)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectBuffer

public ObjectBuffer(Kryo kryo)
Creates an ObjectStream with an initial buffer size of 2KB and a maximum size of 16KB.


ObjectBuffer

public ObjectBuffer(Kryo kryo,
                    int maxCapacity)
Parameters:
maxCapacity - The initial and maximum size in bytes of an object that can be read or written.
See Also:
ObjectBuffer(Kryo, int, int)

ObjectBuffer

public ObjectBuffer(Kryo kryo,
                    int initialCapacity,
                    int maxCapacity)
Parameters:
initialCapacity - The initial maximum size in bytes of an object that can be read or written.
maxCapacity - The maximum size in bytes of an object that can be read or written. The capacity is doubled until the maxCapacity is exceeded, then SerializationException is thrown by the read and write methods.
Method Detail

setKryo

public void setKryo(Kryo kryo)

readClassAndObject

public java.lang.Object readClassAndObject(java.io.InputStream input)
Reads to the end of the stream and returns the deserialized object.

See Also:
Kryo.readClassAndObject(ByteBuffer)

readClassAndObject

public java.lang.Object readClassAndObject(java.io.InputStream input,
                                           int contentLength)
Reads the specified number of bytes and returns the deserialized object.

See Also:
Kryo.readClassAndObject(ByteBuffer)

readObject

public <T> T readObject(java.io.InputStream input,
                        java.lang.Class<T> type)
Reads to the end of the stream and returns the deserialized object.

See Also:
Kryo.readObject(ByteBuffer, Class)

readObject

public <T> T readObject(java.io.InputStream input,
                        int contentLength,
                        java.lang.Class<T> type)
Reads the specified number of bytes and returns the deserialized object.

See Also:
Kryo.readObject(ByteBuffer, Class)

readObjectData

public <T> T readObjectData(java.io.InputStream input,
                            java.lang.Class<T> type)
Reads to the end of the stream and returns the deserialized object.

See Also:
Kryo.readObjectData(ByteBuffer, Class)

readObjectData

public <T> T readObjectData(java.io.InputStream input,
                            int contentLength,
                            java.lang.Class<T> type)
Reads the specified number of bytes and returns the deserialized object.

See Also:
Kryo.readObjectData(ByteBuffer, Class)

writeClassAndObject

public void writeClassAndObject(java.io.OutputStream output,
                                java.lang.Object object)
See Also:
Kryo.writeClassAndObject(ByteBuffer, Object)

writeObject

public void writeObject(java.io.OutputStream output,
                        java.lang.Object object)
See Also:
Kryo.writeObject(ByteBuffer, Object)

writeObjectData

public void writeObjectData(java.io.OutputStream output,
                            java.lang.Object object)
See Also:
Kryo.writeObjectData(ByteBuffer, Object)

readClassAndObject

public java.lang.Object readClassAndObject(byte[] objectBytes)
See Also:
Kryo.readClassAndObject(ByteBuffer)

readObject

public <T> T readObject(byte[] objectBytes,
                        java.lang.Class<T> type)
See Also:
Kryo.readObject(ByteBuffer, Class)

readObjectData

public <T> T readObjectData(byte[] objectBytes,
                            java.lang.Class<T> type)
See Also:
Kryo.readObjectData(ByteBuffer, Class)

writeClassAndObject

public byte[] writeClassAndObject(java.lang.Object object)
See Also:
Kryo.writeClassAndObject(ByteBuffer, Object)

writeObject

public byte[] writeObject(java.lang.Object object)
See Also:
Kryo.writeObject(ByteBuffer, Object)

writeObjectData

public byte[] writeObjectData(java.lang.Object object)
See Also:
Kryo.writeObjectData(ByteBuffer, Object)


Copyright © 2011. All Rights Reserved.