Package jadex.binary
Class SBinarySerializer
- java.lang.Object
-
- jadex.binary.SBinarySerializer
-
public class SBinarySerializer extends java.lang.Object
Object serializer for encoding to and decoding from a compact binary format.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
SBinarySerializer.BinaryWriteTraverser
Traverser for writing.
-
Field Summary
Fields Modifier and Type Field Description static java.util.List<IDecoderHandler>
DECODER_HANDLERS
Handlers for decoding.static java.util.List<ITraverseProcessor>
ENCODER_HANDLERS
Handlers for encoding.protected static byte
MAGIC_BYTE
The magic byte identifying it as a binary serializer 2+ stream.protected static java.lang.String
NULL_MARKER
Marker for null valuesprotected static java.lang.String
REFERENCE_MARKER
Marker for referencesprotected static int
VERSION
Serializer version
-
Constructor Summary
Constructors Constructor Description SBinarySerializer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object
decodeObject(IDecodingContext context)
Helper method for decoding an object (used for recursion).protected static java.lang.Object
decodeRawObject(java.lang.Class<?> clazz, IDecodingContext context)
Method for decoding a raw object where the class is known.static java.lang.Object
readObjectFromByteArray(byte[] val, java.util.List<ITraverseProcessor> postprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader, IErrorReporter errorreporter)
Convert a byte array to an object.static java.lang.Object
readObjectFromDataInput(java.io.DataInput di, java.util.List<ITraverseProcessor> postprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader, IErrorReporter errorreporter, SerializationConfig config)
Convert a byte array to an object.static java.lang.Object
readObjectFromFramedStream(java.io.InputStream is, java.util.List<ITraverseProcessor> postprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader, IErrorReporter errorreporter, SerializationConfig config)
Convert a byte array to an object with framing support.static java.lang.Object
readObjectFromStream(java.io.InputStream is, java.lang.ClassLoader classloader)
Convert a byte array to an object.static java.lang.Object
readObjectFromStream(java.io.InputStream is, java.util.List<ITraverseProcessor> postprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader, IErrorReporter errorreporter, SerializationConfig config)
Convert a byte array to an object.static java.lang.Object
readObjectFromStream(java.io.InputStream is, java.util.List<ITraverseProcessor> postprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader, IErrorReporter errorreporter, SerializationConfig config, java.util.List<IDecoderHandler> decoders)
Convert a byte array to an object.static byte[]
writeObjectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader)
Convert an object to an encoded byte array.static long
writeObjectToDataOutput(java.io.DataOutput dato, java.lang.Object val, java.lang.ClassLoader classloader)
Convert an object to an encoded byte array.static long
writeObjectToDataOutput(java.io.DataOutput dato, java.lang.Object val, java.util.List<ITraverseProcessor> preprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader, SerializationConfig config)
Convert an object to an encoded byte array.static long
writeObjectToDataOutput(java.io.DataOutput dato, java.lang.Object val, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> encoderhandlers, java.lang.Object usercontext, java.lang.ClassLoader classloader, SerializationConfig config)
Convert an object to an encoded byte array.static byte[]
writeObjectToFramedArray(java.lang.Object val, java.lang.ClassLoader classloader)
Convert an object to an encoded byte array with framing support.static byte[]
writeObjectToFramedArray(java.lang.Object val, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> encoderhandlers, java.lang.Object usercontext, java.lang.ClassLoader classloader, SerializationConfig config)
Convert an object to an encoded byte array with framing support.static long
writeObjectToStream(java.io.OutputStream os, java.lang.Object val, java.lang.ClassLoader classloader)
Convert an object to an encoded byte array.static long
writeObjectToStream(java.io.OutputStream os, java.lang.Object val, java.util.List<ITraverseProcessor> preprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader)
Convert an object to an encoded byte array.static long
writeObjectToStream(java.io.OutputStream os, java.lang.Object val, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> encoderhandlers, java.lang.Object usercontext, java.lang.ClassLoader classloader, SerializationConfig config)
Convert an object to an encoded byte array.
-
-
-
Field Detail
-
MAGIC_BYTE
protected static final byte MAGIC_BYTE
The magic byte identifying it as a binary serializer 2+ stream.- See Also:
- Constant Field Values
-
VERSION
protected static final int VERSION
Serializer version- See Also:
- Constant Field Values
-
NULL_MARKER
protected static final java.lang.String NULL_MARKER
Marker for null values- See Also:
- Constant Field Values
-
REFERENCE_MARKER
protected static final java.lang.String REFERENCE_MARKER
Marker for references- See Also:
- Constant Field Values
-
ENCODER_HANDLERS
public static final java.util.List<ITraverseProcessor> ENCODER_HANDLERS
Handlers for encoding.
-
DECODER_HANDLERS
public static final java.util.List<IDecoderHandler> DECODER_HANDLERS
Handlers for decoding.
-
-
Method Detail
-
writeObjectToByteArray
public static byte[] writeObjectToByteArray(java.lang.Object val, java.lang.ClassLoader classloader)
Convert an object to an encoded byte array.- Parameters:
val
- The object being encoded.preprocessors
- List of processors called before the object is encoded, may be null.usercontext
- A user context, may be null.classloader
- The class loader used.- Returns:
- Encoded byte array.
-
writeObjectToStream
public static long writeObjectToStream(java.io.OutputStream os, java.lang.Object val, java.lang.ClassLoader classloader)
Convert an object to an encoded byte array.- Parameters:
val
- The object being encoded.preprocessors
- List of processors called before the object is encoded, may be null.usercontext
- A user context, may be null.classloader
- The class loader used.- Returns:
- Bytes written.
-
writeObjectToStream
public static long writeObjectToStream(java.io.OutputStream os, java.lang.Object val, java.util.List<ITraverseProcessor> preprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader)
Convert an object to an encoded byte array.- Parameters:
val
- The object being encoded.preprocessors
- List of processors called before the object is encoded, may be null.usercontext
- A user context, may be null.classloader
- The class loader used.- Returns:
- Bytes written.
-
writeObjectToStream
public static long writeObjectToStream(java.io.OutputStream os, java.lang.Object val, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> encoderhandlers, java.lang.Object usercontext, java.lang.ClassLoader classloader, SerializationConfig config)
Convert an object to an encoded byte array.- Parameters:
val
- The object being encoded.preprocessors
- List of processors called before the object is encoded, may be null.usercontext
- A user context, may be null.classloader
- The class loader used.- Returns:
- Bytes written.
-
writeObjectToFramedArray
public static byte[] writeObjectToFramedArray(java.lang.Object val, java.lang.ClassLoader classloader)
Convert an object to an encoded byte array with framing support.- Parameters:
val
- The object being encoded.preprocessors
- List of processors called before the object is encoded, may be null.usercontext
- A user context, may be null.classloader
- The class loader used.- Returns:
- Bytes written.
-
writeObjectToFramedArray
public static byte[] writeObjectToFramedArray(java.lang.Object val, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> encoderhandlers, java.lang.Object usercontext, java.lang.ClassLoader classloader, SerializationConfig config)
Convert an object to an encoded byte array with framing support.- Parameters:
val
- The object being encoded.preprocessors
- List of processors called before the object is encoded, may be null.usercontext
- A user context, may be null.classloader
- The class loader used.- Returns:
- Bytes written.
-
writeObjectToDataOutput
public static long writeObjectToDataOutput(java.io.DataOutput dato, java.lang.Object val, java.lang.ClassLoader classloader)
Convert an object to an encoded byte array.- Parameters:
val
- The object being encoded.preprocessors
- List of processors called before the object is encoded, may be null.usercontext
- A user context, may be null.classloader
- The class loader used.- Returns:
- Bytes written.
-
writeObjectToDataOutput
public static long writeObjectToDataOutput(java.io.DataOutput dato, java.lang.Object val, java.util.List<ITraverseProcessor> preprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader, SerializationConfig config)
Convert an object to an encoded byte array.- Parameters:
val
- The object being encoded.preprocessors
- List of processors called before the object is encoded, may be null.usercontext
- A user context, may be null.classloader
- The class loader used.- Returns:
- Bytes written.
-
writeObjectToDataOutput
public static long writeObjectToDataOutput(java.io.DataOutput dato, java.lang.Object val, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> encoderhandlers, java.lang.Object usercontext, java.lang.ClassLoader classloader, SerializationConfig config)
Convert an object to an encoded byte array.- Parameters:
val
- The object being encoded.preprocessors
- List of processors called before the object is encoded, may be null.usercontext
- A user context, may be null.classloader
- The class loader used.- Returns:
- Bytes written.
-
readObjectFromByteArray
public static java.lang.Object readObjectFromByteArray(byte[] val, java.util.List<ITraverseProcessor> postprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader, IErrorReporter errorreporter)
Convert a byte array to an object.- Parameters:
val
- The byte array.usercontext
- A user context, may be null.classloader
- The class loader.errorreporter
- The error reporter, may be null in which case the default reporter is used.- Returns:
- The decoded object.
-
readObjectFromStream
public static java.lang.Object readObjectFromStream(java.io.InputStream is, java.lang.ClassLoader classloader)
Convert a byte array to an object.- Parameters:
val
- The byte array.usercontext
- A user context, may be null.classloader
- The class loader.errorreporter
- The error reporter, may be null in which case the default reporter is used.- Returns:
- The decoded object.
-
readObjectFromStream
public static java.lang.Object readObjectFromStream(java.io.InputStream is, java.util.List<ITraverseProcessor> postprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader, IErrorReporter errorreporter, SerializationConfig config)
Convert a byte array to an object.- Parameters:
val
- The byte array.usercontext
- A user context, may be null.classloader
- The class loader.errorreporter
- The error reporter, may be null in which case the default reporter is used.- Returns:
- The decoded object.
-
readObjectFromStream
public static java.lang.Object readObjectFromStream(java.io.InputStream is, java.util.List<ITraverseProcessor> postprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader, IErrorReporter errorreporter, SerializationConfig config, java.util.List<IDecoderHandler> decoders)
Convert a byte array to an object.- Parameters:
val
- The byte array.usercontext
- A user context, may be null.classloader
- The class loader.errorreporter
- The error reporter, may be null in which case the default reporter is used.- Returns:
- The decoded object.
-
readObjectFromFramedStream
public static java.lang.Object readObjectFromFramedStream(java.io.InputStream is, java.util.List<ITraverseProcessor> postprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader, IErrorReporter errorreporter, SerializationConfig config)
Convert a byte array to an object with framing support.- Parameters:
val
- The byte array.usercontext
- A user context, may be null.classloader
- The class loader.errorreporter
- The error reporter, may be null in which case the default reporter is used.- Returns:
- The decoded object.
-
readObjectFromDataInput
public static java.lang.Object readObjectFromDataInput(java.io.DataInput di, java.util.List<ITraverseProcessor> postprocessors, java.lang.Object usercontext, java.lang.ClassLoader classloader, IErrorReporter errorreporter, SerializationConfig config)
Convert a byte array to an object.- Parameters:
val
- The byte array.usercontext
- A user context, may be null.classloader
- The class loader.errorreporter
- The error reporter, may be null in which case the default reporter is used.- Returns:
- The decoded object.
-
decodeObject
public static java.lang.Object decodeObject(IDecodingContext context)
Helper method for decoding an object (used for recursion).- Parameters:
context
- The decoding context.- Returns:
- Decoded object.
-
decodeRawObject
protected static java.lang.Object decodeRawObject(java.lang.Class<?> clazz, IDecodingContext context)
Method for decoding a raw object where the class is known.- Parameters:
clazz
- The object's class.context
- The decoding context.- Returns:
- Decoded object.
-
-