Package dev.oak3.sbs4j
Class SerializerBuffer
- java.lang.Object
-
- dev.oak3.sbs4j.SerializerBuffer
-
public class SerializerBuffer extends java.lang.Object
Serializing methods- Since:
- 0.1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.math.BigInteger
MAX_U128
static java.math.BigInteger
MAX_U256
static java.math.BigInteger
MAX_U512
static java.math.BigInteger
MAX_U64
static java.math.BigInteger
ONE
static java.math.BigInteger
TWO
static java.math.BigInteger
ZERO
-
Constructor Summary
Constructors Constructor Description SerializerBuffer()
Initializes buffer with initial capacity ofINITIAL_CAPACITY
in bytes andByteOrder.LITTLE_ENDIAN
SerializerBuffer(int initialCapacity, java.nio.ByteOrder byteOrder)
Initializes buffer with given initial capacity in bytes and byte order.SerializerBuffer(java.nio.ByteOrder byteOrder)
Initializes buffer with initial capacity ofINITIAL_CAPACITY
and given byte order.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBuffer
getBuffer()
Retrieves the backing bufferbyte[]
toByteArray()
Gets the full byte array corresponding to serialized dataprotected void
writeBigInteger(java.math.BigInteger value, int size)
Writes a BigInteger/U128-U256-U512 to the value byte buffervoid
writeBool(boolean value)
Writes a boolean value to the value byte buffervoid
writeByteArray(byte[] value)
Writes a byte array valuevoid
writeF32(float value)
Writes a Float/F32 valuevoid
writeF64(double value)
Writes a Double/F64 valuevoid
writeI32(int value)
Writes an Integer/I32 valuevoid
writeI64(long value)
Writes a Long/I64 valuevoid
writeString(java.lang.String value)
Writes a String to the value byte buffervoid
writeU128(java.math.BigInteger value)
Writes a BigInteger/U128 to the value byte buffervoid
writeU256(java.math.BigInteger value)
Writes a BigInteger/U256 to the value byte buffervoid
writeU32(java.lang.Long value)
Writes an Unsigned Integer (Long)/U32void
writeU512(java.math.BigInteger value)
Writes a BigInteger/U512 to the value byte buffervoid
writeU64(java.math.BigInteger value)
Writes an Unsigned Long (BigInteger)/U64 to the value byte buffervoid
writeU8(byte value)
Writes a single byte value
-
-
-
Field Detail
-
ZERO
public static final java.math.BigInteger ZERO
-
ONE
public static final java.math.BigInteger ONE
-
TWO
public static final java.math.BigInteger TWO
-
MAX_U64
public static final java.math.BigInteger MAX_U64
-
MAX_U128
public static final java.math.BigInteger MAX_U128
-
MAX_U256
public static final java.math.BigInteger MAX_U256
-
MAX_U512
public static final java.math.BigInteger MAX_U512
-
-
Constructor Detail
-
SerializerBuffer
public SerializerBuffer()
Initializes buffer with initial capacity ofINITIAL_CAPACITY
in bytes andByteOrder.LITTLE_ENDIAN
-
SerializerBuffer
public SerializerBuffer(java.nio.ByteOrder byteOrder)
Initializes buffer with initial capacity ofINITIAL_CAPACITY
and given byte order.- Parameters:
byteOrder
- the byte order to be using
-
SerializerBuffer
public SerializerBuffer(int initialCapacity, java.nio.ByteOrder byteOrder)
Initializes buffer with given initial capacity in bytes and byte order.- Parameters:
initialCapacity
- the initial capacity of the bufferbyteOrder
- the byte order to be using
-
-
Method Detail
-
writeBool
public void writeBool(boolean value)
Writes a boolean value to the value byte buffer- Parameters:
value
- boolean value to serialize
-
writeU8
public void writeU8(byte value)
Writes a single byte value- Parameters:
value
- byte value to serialize
-
writeByteArray
public void writeByteArray(byte[] value)
Writes a byte array value- Parameters:
value
- byte array value to serialize
-
writeF32
public void writeF32(float value)
Writes a Float/F32 value- Parameters:
value
- F32 value to serialize
-
writeF64
public void writeF64(double value)
Writes a Double/F64 value- Parameters:
value
- F64 value to serialize
-
writeI32
public void writeI32(int value)
Writes an Integer/I32 value- Parameters:
value
- I32 value to serialize
-
writeU32
public void writeU32(java.lang.Long value)
Writes an Unsigned Integer (Long)/U32- Parameters:
value
- U32 value to serialize
-
writeI64
public void writeI64(long value)
Writes a Long/I64 value- Parameters:
value
- I64 value to serialize
-
writeU64
public void writeU64(java.math.BigInteger value) throws ValueSerializationException
Writes an Unsigned Long (BigInteger)/U64 to the value byte buffer- Parameters:
value
- U64 value to serialize error with input/output while reading the byte array- Throws:
ValueSerializationException
- exception holding information of failure to serialize a value
-
writeU128
public void writeU128(java.math.BigInteger value) throws ValueSerializationException
Writes a BigInteger/U128 to the value byte buffer- Parameters:
value
- U128 value to serialize error with input/output while reading the byte array- Throws:
ValueSerializationException
- exception holding information of failure to serialize a value
-
writeU256
public void writeU256(java.math.BigInteger value) throws ValueSerializationException
Writes a BigInteger/U256 to the value byte buffer- Parameters:
value
- U256 value to serialize error with input/output while reading the byte array- Throws:
ValueSerializationException
- exception holding information of failure to serialize a value
-
writeU512
public void writeU512(java.math.BigInteger value) throws ValueSerializationException
Writes a BigInteger/U512 to the value byte buffer- Parameters:
value
- U512 value to serialize error with input/output while reading the byte array- Throws:
ValueSerializationException
- exception holding information of failure to serialize a value
-
writeBigInteger
protected void writeBigInteger(java.math.BigInteger value, int size) throws ValueSerializationException
Writes a BigInteger/U128-U256-U512 to the value byte buffer- Parameters:
value
- BigInteger to serializesize
- the bit size of BigInteger error with input/output while reading the byte array- Throws:
ValueSerializationException
- exception holding information of failure to serialize a value
-
writeString
public void writeString(java.lang.String value)
Writes a String to the value byte buffer- Parameters:
value
- String value to serialize error with input/output while reading the byte array
-
getBuffer
public java.nio.ByteBuffer getBuffer()
Retrieves the backing buffer- Returns:
- the Deserializer ByteBuffer
-
toByteArray
public byte[] toByteArray()
Gets the full byte array corresponding to serialized data- Returns:
- the byte array serialized data
-
-