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