|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.helidb.lang.serializer.DoubleSerializer
public class DoubleSerializer
A Serializer
for Double
values. Double
values are serialized to eight bytes long byte arrays.
This object uses Double.doubleToRawLongBits(double)
to encode double
values. That method creates special codes for the special values
Double.NaN
, Double.POSITIVE_INFINITY
and
Double.NEGATIVE_INFINITY
, and they are preserved by this object's
serialization and interpretation.
This serializer does not handle null
values.
The singleton instance INSTANCE
may be used instead of creating a
new object of this class.
Double
Field Summary | |
---|---|
static int |
DATA_SIZE
Eight bytes. |
static DoubleSerializer |
INSTANCE
The singleton instance. |
Constructor Summary | |
---|---|
DoubleSerializer()
|
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). |
Double |
interpret(byte[] barr)
Interpret the data in the byte array to an object of the type
handled by the Serializer implementation. |
Double |
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? |
Double |
read(InputStream is,
int dataSize)
Read a value from the InputStream . |
Double |
read(RandomAccess ra,
int dataSize)
Read a value from the RandomAccess ' current position. |
Double |
readDouble(InputStream is)
Read a Double value from the current position of the InputStream . |
Double |
readDouble(RandomAccess ra)
Read a Double value from the current position of the RandomAccess . |
byte[] |
serialize(Double value)
Serialize the supplied object into a new byte array. |
int |
serialize(Double 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 DoubleSerializer INSTANCE
public static final int DATA_SIZE
Constructor Detail |
---|
public DoubleSerializer()
Method Detail |
---|
public Double 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<Double>
barr
- The byte
array containing the data.offset
- The start position of the data.length
- The length of the data.
Serializer.interpret(byte[])
public Double interpret(byte[] barr)
Serializer
byte
array to an object of the type
handled by the Serializer
implementation.
interpret
in interface Serializer<Double>
barr
- The byte
array containing the data.
Serializer.interpret(byte[], int, int)
public int serialize(Double value, byte[] barr, int offset)
Serializer
byte
array.
serialize
in interface Serializer<Double>
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(Double value)
Serializer
byte
array.
serialize
in interface Serializer<Double>
value
- The object to serialize.
byte
array.public int getSerializedSize()
Serializer
-1
is
returned.
getSerializedSize
in interface Serializer<Double>
public boolean isNullValuesPermitted()
Serializer
null
values?
isNullValuesPermitted
in interface Serializer<Double>
false
, always.public Double readDouble(RandomAccess ra) throws NotEnoughDataException, WrappedIOException
Double
value from the current position of the RandomAccess
.
ra
- The RandomAccess
to read from. The current position of
this is incremented by 8 bytes.
Double
value.
NotEnoughDataException
- If 8 bytes cannot be
read.
WrappedIOException
- On I/O errors.public Double readDouble(InputStream is) throws NotEnoughDataException, WrappedIOException
Double
value from the current position of the InputStream
.
is
- The InputStream
to read from. The current position of
the stream is incremented by 8 bytes.
Double
value.
NotEnoughDataException
- If 8 bytes cannot be
read.
WrappedIOException
- If an IOException
is encountered while
reading data.public Double read(RandomAccess ra, int dataSize)
Serializer
RandomAccess
' current position. The
position in the RandomAccess
is incremented by size
bytes.
read
in interface Serializer<Double>
ra
- The RandomAccess
to read from.dataSize
- The size of the value.
public Double read(InputStream is, int dataSize)
Serializer
InputStream
.
read
in interface Serializer<Double>
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 |