|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.helidb.lang.serializer.UnsignedByteSerializer
public class UnsignedByteSerializer
A Serializer
for unsigned byte values (between 0 and 255). Every
unsigned byte value serialized by this object is represented as a byte array
of length one. Deserialized values are represented by Short
objects.
This serializer does not handle null
values.
The singleton instance INSTANCE
may be used instead of creating a
new object of this class.
Byte
,
ByteSerializer
Field Summary | |
---|---|
static int |
DATA_SIZE
One byte. |
static UnsignedByteSerializer |
INSTANCE
The singleton instance. |
Constructor Summary | |
---|---|
UnsignedByteSerializer()
|
Method Summary | |
---|---|
int |
getSerializedSize()
If the serialized data produced by this serializer always is of the same size, return that size (in number of bytes). |
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 |
readUnsignedByte(InputStream is)
Read an unsigned byte value from the current position of the InputStream . |
Short |
readUnsignedByte(RandomAccess ra)
Read an unsigned byte 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[] arr,
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 UnsignedByteSerializer INSTANCE
public static final int DATA_SIZE
Constructor Detail |
---|
public UnsignedByteSerializer()
Method Detail |
---|
public Short interpret(byte[] barr, int offset, int length)
Serializer
byte
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)
Serializer
byte
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 int serialize(Short value, byte[] arr, int offset)
Serializer
byte
array.
serialize
in interface Serializer<Short>
value
- The object to serialize.arr
- The byte array to serialize it to.offset
- The start position to write data at in the byte array.
public byte[] serialize(Short value)
Serializer
byte
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()
Serializer
null
values?
isNullValuesPermitted
in interface Serializer<Short>
false
, always.public Short readUnsignedByte(RandomAccess ra) throws NotEnoughDataException, WrappedIOException
RandomAccess
.
ra
- The RandomAccess
to read from. The current position of
this is incremented by 1 bytes.
Short
value
between 0 and 255.
DatabaseException
- If 1 bytes cannot be read.
WrappedIOException
- On I/O errors.
NotEnoughDataException
public Short readUnsignedByte(InputStream is) throws NotEnoughDataException, WrappedIOException
InputStream
.
is
- The InputStream
to read from. The current position of
the stream is incremented by 1 bytes.
Short
value
between 0 and 255.
NotEnoughDataException
- If 1 bytes cannot be
read.
WrappedIOException
- If an IOException
is encountered while
reading data.public Short read(RandomAccess ra, int dataSize)
Serializer
RandomAccess
' 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)
Serializer
InputStream
.
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 |