|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.helidb.lang.serializer.ShortSerializer
public class ShortSerializer
A Serializer for Short values. Short values
are serialized to two bytes long, big-endian byte arrays.
This serializer does not handle null values.
The singleton instance INSTANCE may be used instead of creating a
new object of this class.
ShortNullSerializer,
Short| Field Summary | |
|---|---|
static int |
DATA_SIZE
Two bytes. |
static ShortSerializer |
INSTANCE
The singleton instance. |
| Constructor Summary | |
|---|---|
ShortSerializer()
|
|
| Method Summary | |
|---|---|
static byte[] |
encodeShort(short s)
Encode a short value to a two bytes long, big-endian byte array. |
int |
getSerializedSize()
If the serialized data produced by this serializer always is of the same size, return that size (in number of bytes). |
static short |
getShort(byte[] barr)
Get the short value encoded in the byte array. |
Short |
interpret(byte[] barr)
Interpret the data in the byte array to an object of the type
handled by the Serializer implementation. |
Short |
interpret(byte[] barr,
int offset,
int length)
Interpret the data in the byte array to an object of the type
handled by the Serializer implementation. |
boolean |
isNullValuesPermitted()
Does this serializer permit null values? |
Short |
read(InputStream is,
int dataSize)
Read a value from the InputStream. |
Short |
read(RandomAccess ra,
int dataSize)
Read a value from the RandomAccess' current position. |
Short |
readShort(InputStream is)
Read a Short value from the current position of the InputStream. |
Short |
readShort(RandomAccess ra)
Read a Short value from the current position of the RandomAccess. |
byte[] |
serialize(Short value)
Serialize the supplied object into a new byte array. |
int |
serialize(Short value,
byte[] barr,
int offset)
Serialize the supplied object into the byte array. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final ShortSerializer INSTANCE
public static final int DATA_SIZE
| Constructor Detail |
|---|
public ShortSerializer()
| Method Detail |
|---|
public static short getShort(byte[] barr)
throws SerializationException,
NullPointerException
short value encoded in the byte array.
barr - The byte array. It must be two bytes long and big-endian.
SerializationException - If the array length is different from two
bytes.
NullPointerException - If barr is nullencodeShort(short)
public Short interpret(byte[] barr,
int offset,
int length)
Serializerbyte array to an object of the type
handled by the Serializer implementation.
interpret in interface Serializer<Short>barr - The byte array containing the data.offset - The start position of the data.length - The length of the data.
Serializer.interpret(byte[])public Short interpret(byte[] barr)
Serializerbyte array to an object of the type
handled by the Serializer implementation.
interpret in interface Serializer<Short>barr - The byte array containing the data.
Serializer.interpret(byte[], int, int)public static byte[] encodeShort(short s)
s - The short to encode.
public int serialize(Short value,
byte[] barr,
int offset)
Serializerbyte array.
serialize in interface Serializer<Short>value - The object to serialize.barr - The byte array to serialize it to.offset - The start position to write data at in the byte array.
public byte[] serialize(Short value)
Serializerbyte array.
serialize in interface Serializer<Short>value - The object to serialize.
byte array.public int getSerializedSize()
Serializer-1 is
returned.
getSerializedSize in interface Serializer<Short>public boolean isNullValuesPermitted()
Serializernull values?
isNullValuesPermitted in interface Serializer<Short>false, always.
public Short readShort(RandomAccess ra)
throws NotEnoughDataException,
WrappedIOException
Short value from the current position of the RandomAccess.
ra - The RandomAccess to read from. The current position of
this is incremented by 2 bytes.
Short value.
NotEnoughDataException - If 2 bytes cannot be
read.
WrappedIOException - On I/O errors.
public Short readShort(InputStream is)
throws NotEnoughDataException,
WrappedIOException
Short value from the current position of the InputStream.
is - The InputStream to read from. The current position of
the stream is incremented by 2 bytes.
Short value.
NotEnoughDataException - If 2 bytes cannot be
read.
WrappedIOException - If an IOException is encountered while
reading data.
public Short read(RandomAccess ra,
int dataSize)
SerializerRandomAccess' current position. The
position in the RandomAccess is incremented by size
bytes.
read in interface Serializer<Short>ra - The RandomAccess to read from.dataSize - The size of the value.
public Short read(InputStream is,
int dataSize)
SerializerInputStream.
read in interface Serializer<Short>is - The InputStream to read from.dataSize - The size of the value.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||