|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.helidb.lang.serializer.IntegerSerializer
public class IntegerSerializer
A Serializer for Integer values. Integer
values are serialized to a four bytes long, big-endian byte array.
This serializer does not handle null values.
The singleton instance INSTANCE may be used instead of creating a
new object of this class.
IntegerNullSerializer,
ConfigurableLengthIntegerSerializer,
Integer| Field Summary | |
|---|---|
static int |
DATA_SIZE
Four bytes. |
static IntegerSerializer |
INSTANCE
The singleton instance. |
| Constructor Summary | |
|---|---|
IntegerSerializer()
|
|
| Method Summary | |
|---|---|
static byte[] |
encodeInteger(int i)
Encode an integer to a four bytes long, big-endian byte array. |
static int |
getInteger(byte[] barr)
Get the int value encoded in the 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). |
Integer |
interpret(byte[] barr)
Interpret the data in the byte array to an object of the type
handled by the Serializer implementation. |
Integer |
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? |
Integer |
read(InputStream is,
int dataSize)
Read a value from the InputStream. |
Integer |
read(RandomAccess ra,
int dataSize)
Read a value from the RandomAccess' current position. |
Integer |
readInteger(InputStream is)
Read an Integer value from the current position of the InputStream. |
Integer |
readInteger(RandomAccess ra)
Read an Integer value from the current position of the RandomAccess. |
byte[] |
serialize(Integer value)
Serialize the supplied object into a new byte array. |
int |
serialize(Integer 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 IntegerSerializer INSTANCE
public static final int DATA_SIZE
| Constructor Detail |
|---|
public IntegerSerializer()
| Method Detail |
|---|
public static int getInteger(byte[] barr)
throws SerializationException,
NullPointerException
int value encoded in the big-endian, byte array.
barr - The byte array. It must be four bytes long and big-endian.
SerializationException - If the array length is different from four
bytes.
NullPointerException - If barr is nullencodeInteger(int)
public Integer interpret(byte[] barr,
int offset,
int length)
Serializerbyte array to an object of the type
handled by the Serializer implementation.
interpret in interface Serializer<Integer>barr - The byte array containing the data.offset - The start position of the data.length - The length of the data.
Serializer.interpret(byte[])public Integer interpret(byte[] barr)
Serializerbyte array to an object of the type
handled by the Serializer implementation.
interpret in interface Serializer<Integer>barr - The byte array containing the data.
Serializer.interpret(byte[], int, int)public static byte[] encodeInteger(int i)
i - The integer to encode.
public int serialize(Integer value,
byte[] barr,
int offset)
Serializerbyte array.
serialize in interface Serializer<Integer>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(Integer value)
Serializerbyte array.
serialize in interface Serializer<Integer>value - The object to serialize.
byte array.public int getSerializedSize()
Serializer-1 is
returned.
getSerializedSize in interface Serializer<Integer>public boolean isNullValuesPermitted()
Serializernull values?
isNullValuesPermitted in interface Serializer<Integer>false, always.
public Integer readInteger(RandomAccess ra)
throws NotEnoughDataException,
WrappedIOException
Integer value from the current position of the RandomAccess.
ra - The RandomAccess to read from. The current position of
this is incremented by 4 bytes.
Integer value.
NotEnoughDataException - If 4 bytes cannot be
read.
WrappedIOException - On I/O errors.
public Integer readInteger(InputStream is)
throws NotEnoughDataException,
WrappedIOException
Integer value from the current position of the InputStream.
is - The InputStream to read from. The current position of
the stream is incremented by 4 bytes.
Integer value.
NotEnoughDataException - If 4 bytes cannot be
read.
WrappedIOException - If an IOException is encountered while
reading data.
public Integer read(RandomAccess ra,
int dataSize)
SerializerRandomAccess' current position. The
position in the RandomAccess is incremented by size
bytes.
read in interface Serializer<Integer>ra - The RandomAccess to read from.dataSize - The size of the value.
public Integer read(InputStream is,
int dataSize)
SerializerInputStream.
read in interface Serializer<Integer>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 | ||||||||