|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.helidb.lang.serializer.FixedSizeBigIntegerSerializer
org.helidb.lang.serializer.FixedSizeBigIntegerNullSerializer
public class FixedSizeBigIntegerNullSerializer
This Serializer serializes BigInteger values to a
big-endian byte array of configurable size using BigInteger's
constructor and toByteArray methods.
A value is serialized to a big-endian byte arrays using BigInteger 's
constructor and toByteArray methods. Before the array containing the
BigInteger data, the serialized value contains a size value of the
BigInteger data (which may be less than the fixed size of this
object). For fixed sizes of less than 256 bytes, one unsigned byte is used to
represent the size. For sizes of 256 bytes or larger, a signed integer (four
bytes) is used for the size.
The configured size of this object determines how big the serialized BigInteger:s can be. For an object size of of n bytes, where n is less than or equal to 256 bytes, the maximum BigInteger value
is 2^((n - 1)*8 - 1) - 1 and the minimum value is -2^((n -
1)*8 - 1). For n values larger than 256, the maximum value is
2^((n - 4)*8 - 1) - 1 and the minimum value is -2^((n - 4)*8 -
1).
This serializer uses a special, configurable value to represent null
BigInteger:s.
FixedSizeBigIntegerSerializer,
ConfigurableLengthLongNullSerializer,
BigInteger| Constructor Summary | |
|---|---|
FixedSizeBigIntegerNullSerializer(int dataSize)
Create a new Serializer. |
|
FixedSizeBigIntegerNullSerializer(int dataSize,
BigInteger nullValue)
Create a new Serializer. |
|
| Method Summary | |
|---|---|
BigInteger |
interpret(byte[] barr)
Interpret the data in the byte array to an object of the type
handled by the Serializer implementation. |
BigInteger |
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? |
byte[] |
serialize(BigInteger val)
Serialize the supplied object into a new byte array. |
int |
serialize(BigInteger val,
byte[] barr,
int offset)
Serialize the supplied object into the byte array. |
| Methods inherited from class org.helidb.lang.serializer.FixedSizeBigIntegerSerializer |
|---|
getMaxBigIntSize, getSerializedSize, read, read, readBigInteger, readBigInteger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FixedSizeBigIntegerNullSerializer(int dataSize)
throws IllegalArgumentException
Serializer. The special null value is the
lowest value allowed with the given data size - -2^(dataSize*8 -
1). For instance, if the data size is two bytes, the null value will be
-32768. That null value has the most significant bit of
the most significant byte set, which may be important to know when
working with Hasher:s.
dataSize - The size of serialized values in bytes. If the data size
is 256 bytes or less, one unsigned byte is used to represent the size of
the BigInteger byte array. If the data size is greater than 256
bytes, a total of five bytes is used to represent the size of the BigInteger byte array. The byte or bytes used for representing the data
size are included in this parameter.
IllegalArgumentException - If the data size is less than one byte.
public FixedSizeBigIntegerNullSerializer(int dataSize,
BigInteger nullValue)
throws IllegalArgumentException
Serializer.
dataSize - The size of serialized values in bytes. If the data size
is 256 bytes or less, one unsigned byte is used to represent the size of
the BigInteger byte array. If the data size is greater than 256
bytes, a total of five bytes is used to represent the size of the BigInteger byte array. The byte or bytes used for representing the data
size are included in this parameter.nullValue - The BigInteger value used to represent null values.
IllegalArgumentException - If the data size is less than one byte
or if the null value cannot be serialized to a byte array with a
permitted size.| Method Detail |
|---|
public boolean isNullValuesPermitted()
Serializernull values?
isNullValuesPermitted in interface Serializer<BigInteger>isNullValuesPermitted in class FixedSizeBigIntegerSerializertrue, always.
public BigInteger interpret(byte[] barr,
int offset,
int length)
Serializerbyte array to an object of the type
handled by the Serializer implementation.
interpret in interface Serializer<BigInteger>interpret in class FixedSizeBigIntegerSerializerbarr - The byte array containing the data.offset - The start position of the data.length - The length of the data.
Serializer.interpret(byte[])public BigInteger interpret(byte[] barr)
Serializerbyte array to an object of the type
handled by the Serializer implementation.
interpret in interface Serializer<BigInteger>interpret in class FixedSizeBigIntegerSerializerbarr - The byte array containing the data.
Serializer.interpret(byte[], int, int)
public int serialize(BigInteger val,
byte[] barr,
int offset)
Serializerbyte array.
serialize in interface Serializer<BigInteger>serialize in class FixedSizeBigIntegerSerializerval - 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(BigInteger val)
Serializerbyte array.
serialize in interface Serializer<BigInteger>serialize in class FixedSizeBigIntegerSerializerval - The object to serialize.
byte array.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||