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 classTraverser 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 byteThe magic byte identifying it as a binary serializer 2+ stream.protected static final StringMarker for null valuesprotected static final StringMarker for referencesprotected static final intSerializer version -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectdecodeObject(IDecodingContext context) Helper method for decoding an object (used for recursion).protected static ObjectdecodeRawObject(Class<?> clazz, IDecodingContext context) Method for decoding a raw object where the class is known.static ObjectreadObjectFromByteArray(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 ObjectreadObjectFromDataInput(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 ObjectreadObjectFromFramedStream(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 ObjectreadObjectFromStream(InputStream is, ClassLoader classloader) Convert a byte array to an object.static ObjectreadObjectFromStream(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 ObjectreadObjectFromStream(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 longwriteObjectToDataOutput(DataOutput dato, Object val, ClassLoader classloader) Convert an object to an encoded byte array.static longwriteObjectToDataOutput(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 longwriteObjectToDataOutput(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 longwriteObjectToStream(OutputStream os, Object val, ClassLoader classloader) Convert an object to an encoded byte array.static longwriteObjectToStream(OutputStream os, Object val, List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors, Object usercontext, ClassLoader classloader) Convert an object to an encoded byte array.static longwriteObjectToStream(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.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
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, 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.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(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.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, 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:
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 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:
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 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:
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 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:
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 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:
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
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.
-