Package org.onlab.util
Class KryoNamespace
- java.lang.Object
- 
- org.onlab.util.KryoNamespace
 
- 
- All Implemented Interfaces:
- com.esotericsoftware.kryo.pool.KryoFactory,- com.esotericsoftware.kryo.pool.KryoPool
 
 public final class KryoNamespace extends java.lang.Object implements com.esotericsoftware.kryo.pool.KryoFactory, com.esotericsoftware.kryo.pool.KryoPoolPool of Kryo instances, with classes pre-registered.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classKryoNamespace.BuilderKryoNamespace builder.
 - 
Field SummaryFields Modifier and Type Field Description static intDEFAULT_BUFFER_SIZEDefault buffer size used for serialization.static intFLOATING_IDID to use if this KryoNamespace does not define registration id.static intINITIAL_IDSmallest ID free to use for user defined registrations.static intMAX_BUFFER_SIZE
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.esotericsoftware.kryo.Kryoborrow()com.esotericsoftware.kryo.Kryocreate()Creates a Kryo instance.<T> Tdeserialize(byte[] bytes)Deserializes given byte array to Object using Kryo instance in pool.<T> Tdeserialize(java.io.InputStream stream)Deserializes given InputStream to an Object using Kryo instance in pool.<T> Tdeserialize(java.io.InputStream stream, int bufferSize)Deserializes given InputStream to an Object using Kryo instance in pool.<T> Tdeserialize(java.nio.ByteBuffer buffer)Deserializes given byte buffer to Object using Kryo instance in pool.static KryoNamespace.BuildernewBuilder()Creates a newKryoNamespacebuilder.KryoNamespacepopulate(int instances)Populates the Kryo pool.voidrelease(com.esotericsoftware.kryo.Kryo kryo)<T> Trun(com.esotericsoftware.kryo.pool.KryoCallback<T> callback)byte[]serialize(java.lang.Object obj)Serializes given object to byte array using Kryo instance in pool.byte[]serialize(java.lang.Object obj, int bufferSize)Serializes given object to byte array using Kryo instance in pool.voidserialize(java.lang.Object obj, java.io.OutputStream stream)Serializes given object to OutputStream using Kryo instance in pool.voidserialize(java.lang.Object obj, java.io.OutputStream stream, int bufferSize)Serializes given object to OutputStream using Kryo instance in pool.voidserialize(java.lang.Object obj, java.nio.ByteBuffer buffer)Serializes given object to byte buffer using Kryo instance in pool.intsize()Gets the number of classes registered in this Kryo namespace.java.lang.StringtoString()
 
- 
- 
- 
Field Detail- 
DEFAULT_BUFFER_SIZEpublic static final int DEFAULT_BUFFER_SIZE Default buffer size used for serialization.- See Also:
- serialize(Object), Constant Field Values
 
 - 
MAX_BUFFER_SIZEpublic static final int MAX_BUFFER_SIZE - See Also:
- Constant Field Values
 
 - 
FLOATING_IDpublic static final int FLOATING_ID ID to use if this KryoNamespace does not define registration id.- See Also:
- Constant Field Values
 
 - 
INITIAL_IDpublic static final int INITIAL_ID Smallest ID free to use for user defined registrations.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
newBuilderpublic static KryoNamespace.Builder newBuilder() Creates a newKryoNamespacebuilder.- Returns:
- builder
 
 - 
populatepublic KryoNamespace populate(int instances) Populates the Kryo pool.- Parameters:
- instances- to add to the pool
- Returns:
- this
 
 - 
serializepublic byte[] serialize(java.lang.Object obj) Serializes given object to byte array using Kryo instance in pool.Note: Serialized bytes must be smaller than MAX_BUFFER_SIZE.- Parameters:
- obj- Object to serialize
- Returns:
- serialized bytes
 
 - 
serializepublic byte[] serialize(java.lang.Object obj, int bufferSize)Serializes given object to byte array using Kryo instance in pool.- Parameters:
- obj- Object to serialize
- bufferSize- maximum size of serialized bytes
- Returns:
- serialized bytes
 
 - 
serializepublic void serialize(java.lang.Object obj, java.nio.ByteBuffer buffer)Serializes given object to byte buffer using Kryo instance in pool.- Parameters:
- obj- Object to serialize
- buffer- to write to
 
 - 
serializepublic void serialize(java.lang.Object obj, java.io.OutputStream stream)Serializes given object to OutputStream using Kryo instance in pool.- Parameters:
- obj- Object to serialize
- stream- to write to
 
 - 
serializepublic void serialize(java.lang.Object obj, java.io.OutputStream stream, int bufferSize)Serializes given object to OutputStream using Kryo instance in pool.- Parameters:
- obj- Object to serialize
- stream- to write to
- bufferSize- size of the buffer in front of the stream
 
 - 
deserializepublic <T> T deserialize(byte[] bytes) Deserializes given byte array to Object using Kryo instance in pool.- Type Parameters:
- T- deserialized Object type
- Parameters:
- bytes- serialized bytes
- Returns:
- deserialized Object
 
 - 
deserializepublic <T> T deserialize(java.nio.ByteBuffer buffer) Deserializes given byte buffer to Object using Kryo instance in pool.- Type Parameters:
- T- deserialized Object type
- Parameters:
- buffer- input with serialized bytes
- Returns:
- deserialized Object
 
 - 
deserializepublic <T> T deserialize(java.io.InputStream stream) Deserializes given InputStream to an Object using Kryo instance in pool.- Type Parameters:
- T- deserialized Object type
- Parameters:
- stream- input stream
- Returns:
- deserialized Object
 
 - 
deserializepublic <T> T deserialize(java.io.InputStream stream, int bufferSize)Deserializes given InputStream to an Object using Kryo instance in pool.- Type Parameters:
- T- deserialized Object type
- Parameters:
- stream- input stream
- bufferSize- size of the buffer in front of the stream
- Returns:
- deserialized Object
 
 - 
sizepublic int size() Gets the number of classes registered in this Kryo namespace.- Returns:
- size of namespace
 
 - 
createpublic com.esotericsoftware.kryo.Kryo create() Creates a Kryo instance.- Specified by:
- createin interface- com.esotericsoftware.kryo.pool.KryoFactory
- Returns:
- Kryo instance
 
 - 
borrowpublic com.esotericsoftware.kryo.Kryo borrow() - Specified by:
- borrowin interface- com.esotericsoftware.kryo.pool.KryoPool
 
 - 
releasepublic void release(com.esotericsoftware.kryo.Kryo kryo) - Specified by:
- releasein interface- com.esotericsoftware.kryo.pool.KryoPool
 
 - 
runpublic <T> T run(com.esotericsoftware.kryo.pool.KryoCallback<T> callback) - Specified by:
- runin interface- com.esotericsoftware.kryo.pool.KryoPool
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-