com.esotericsoftware.kryo.serialize
Class ShortSerializer

java.lang.Object
  extended by com.esotericsoftware.kryo.Serializer
      extended by com.esotericsoftware.kryo.serialize.ShortSerializer

public class ShortSerializer
extends Serializer

Writes a 1-3 byte short.

Author:
Nathan Sweet

Constructor Summary
ShortSerializer()
           
ShortSerializer(java.lang.Boolean optimizePositive)
           
 
Method Summary
static short get(java.nio.ByteBuffer buffer, boolean optimizePositive)
          Reads a short from the buffer that was written with put(ByteBuffer, short, boolean).
static short put(java.nio.ByteBuffer buffer, short value, boolean optimizePositive)
          Writes the specified short to the buffer as a byte or short depending on the size of the number.
 java.lang.Short readObjectData(java.nio.ByteBuffer buffer, java.lang.Class type)
          Reads an object from the buffer.
 void writeObjectData(java.nio.ByteBuffer buffer, java.lang.Object object)
          Writes the object to the buffer.
 
Methods inherited from class com.esotericsoftware.kryo.Serializer
isFinal, newInstance, readObject, setCanBeNull, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShortSerializer

public ShortSerializer()

ShortSerializer

public ShortSerializer(java.lang.Boolean optimizePositive)
Parameters:
optimizePositive - If true, writes 1 byte if 0 <= value <= 254 and 3 bytes otherwise (default). If false, writes 1 byte if -127 <= value <= 127 and 3 bytes otherwise. If null, 2 bytes are always written.
Method Detail

readObjectData

public java.lang.Short readObjectData(java.nio.ByteBuffer buffer,
                                      java.lang.Class type)
Description copied from class: Serializer
Reads an object from the buffer.

Specified by:
readObjectData in class Serializer
Returns:
The deserialized object, never null.

writeObjectData

public void writeObjectData(java.nio.ByteBuffer buffer,
                            java.lang.Object object)
Description copied from class: Serializer
Writes the object to the buffer.

Specified by:
writeObjectData in class Serializer
object - Cannot be null.

put

public static short put(java.nio.ByteBuffer buffer,
                        short value,
                        boolean optimizePositive)
Writes the specified short to the buffer as a byte or short depending on the size of the number.

Parameters:
optimizePositive - If true, writes 1 byte if 0 <= value <= 254 and 3 bytes otherwise. If false, writes 1 byte if -127 <= value <= 127 and 3 bytes otherwise.
Returns:
the number of bytes written.

get

public static short get(java.nio.ByteBuffer buffer,
                        boolean optimizePositive)
Reads a short from the buffer that was written with put(ByteBuffer, short, boolean).



Copyright © 2011. All Rights Reserved.