public class IntSerializer extends Serializer
Constructor and Description |
---|
IntSerializer() |
IntSerializer(boolean optimizePositive) |
Modifier and Type | Method and Description |
---|---|
static boolean |
canRead(java.nio.ByteBuffer buffer,
boolean optimizePositive)
Reads true if the buffer contains enough data to read an int that was written with
put(ByteBuffer, int, boolean) . |
static int |
get(java.nio.ByteBuffer buffer,
boolean optimizePositive)
Reads an int from the buffer that was written with
put(ByteBuffer, int, boolean) . |
static int |
length(int value,
boolean optimizePositive)
Reads true if the buffer contains enough data to read an int that was written with
put(ByteBuffer, int, boolean) . |
static int |
put(java.nio.ByteBuffer buffer,
int value,
boolean optimizePositive)
Writes the specified int to the buffer using 1 to 5 bytes, depending on the size of the number.
|
java.lang.Integer |
readObjectData(java.nio.ByteBuffer buffer,
java.lang.Class type)
Reads an object from the buffer.
|
void |
writeObjectData(java.nio.ByteBuffer buffer,
java.lang.Object object)
Writes the object to the buffer.
|
isFinal, newInstance, readObject, setCanBeNull, writeObject
public IntSerializer()
public IntSerializer(boolean optimizePositive)
optimizePositive
- Determines how many bytes are written to serialize various ranges of integers:
Bytes | true | false |
1 | 0 <= value <= 127 | -64 <= value <= 63 |
2 | 128 <= value <= 16383 | -8192 <= value <= 8191 |
3 | 16384 <= value <= 2097151 | -1048576 <= value <= 1048575 |
4 | 2097152 <= value <= 268435455 | -134217728 <= value <= 134217727 |
5 | value < 0 || value > 268435455 | value < -134217728 || value > 134217727 |
public java.lang.Integer readObjectData(java.nio.ByteBuffer buffer, java.lang.Class type)
Serializer
readObjectData
in class Serializer
public void writeObjectData(java.nio.ByteBuffer buffer, java.lang.Object object)
Serializer
writeObjectData
in class Serializer
object
- Cannot be null.public static int put(java.nio.ByteBuffer buffer, int value, boolean optimizePositive)
optimizePositive
- See IntSerializer(boolean)
.public static int get(java.nio.ByteBuffer buffer, boolean optimizePositive)
put(ByteBuffer, int, boolean)
.public static boolean canRead(java.nio.ByteBuffer buffer, boolean optimizePositive)
put(ByteBuffer, int, boolean)
.public static int length(int value, boolean optimizePositive)
put(ByteBuffer, int, boolean)
.