org.simantics.databoard.serialization
Class BinarySerializationFormat
java.lang.Object
org.simantics.databoard.serialization.BinarySerializationFormat
- All Implemented Interfaces:
- Binding.Visitor<Serializer>, SerializationFormat
public class BinarySerializationFormat
- extends java.lang.Object
- implements SerializationFormat
BinarySerializationFormat serializes instances to byte format.
BinarySerializationFormat does not throw SerializationConstructionException.
The serialization notation is available at
Binary Serialization format
TODO Ensure java.lang.IndexOutOfBoundsException and other exceptions are not thrown when deserializing
wrong binary data. Instead throw SerializationException
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INSTANCE
public static final BinarySerializationFormat INSTANCE
UTF8
public static final java.nio.charset.Charset UTF8
BinarySerializationFormat
public BinarySerializationFormat()
visit
public Serializer visit(ArrayBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
visit
public Serializer visit(BooleanBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
visit
public Serializer visit(DoubleBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
visit
public Serializer visit(FloatBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
visit
public Serializer visit(IntegerBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
visit
public Serializer visit(ByteBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
visit
public Serializer visit(LongBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
visit
public Serializer visit(OptionalBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
visit
public Serializer visit(RecordBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
visit
public Serializer visit(StringBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
visit
public Serializer visit(UnionBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
visit
public Serializer visit(VariantBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
visit
public Serializer visit(MapBinding b)
- Specified by:
visit
in interface Binding.Visitor<Serializer>
getSizeOfPutLength
public static int getSizeOfPutLength(int length)
- Get the number of bytes it takes to output length field of value
length
.
- Parameters:
length
- length value
- Returns:
- bytes required
getSizeOfPutLengthForArray
public static int getSizeOfPutLengthForArray(int length)
putLength
public static void putLength(BinaryWriteable out,
int length)
throws java.io.IOException
- Throws:
java.io.IOException
getLength
public static int getLength(BinaryReadable in)
throws java.io.IOException
- Throws:
java.io.IOException
putUInt24
public static void putUInt24(BinaryWriteable out,
int value)
throws java.io.IOException
- Throws:
java.io.IOException
getUInt24
public static int getUInt24(BinaryReadable in)
throws java.io.IOException
- Throws:
java.io.IOException
putUInt
public static void putUInt(BinaryWriteable out,
int value,
int maxValue)
throws java.io.IOException
- Throws:
java.io.IOException
getUInt
public static int getUInt(BinaryReadable in,
int maxValue)
throws java.io.IOException
- Throws:
java.io.IOException
getUIntLength
public static int getUIntLength(int maxValue)
getStringUTF8EncodedByteLength
public static int getStringUTF8EncodedByteLength(java.lang.String string)