Package jadex.binary

Class SBinarySerializer

java.lang.Object
jadex.binary.SBinarySerializer

public class SBinarySerializer extends Object
Object serializer for encoding to and decoding from a compact binary format.
  • Field Details

    • MAGIC_BYTE

      protected static final byte MAGIC_BYTE
      The magic byte identifying it as a binary serializer 2+ stream.
      See Also:
    • VERSION

      protected static final int VERSION
      Serializer version
      See Also:
    • NULL_MARKER

      protected static final String NULL_MARKER
      Marker for null values
      See Also:
    • REFERENCE_MARKER

      protected static final String REFERENCE_MARKER
      Marker for references
      See Also:
    • ENCODER_HANDLERS

      public static final List<jadex.common.transformation.traverser.ITraverseProcessor> ENCODER_HANDLERS
      Handlers for encoding.
    • DECODER_HANDLERS

      public static final List<IDecoderHandler> DECODER_HANDLERS
      Handlers for decoding.
  • Constructor Details

    • SBinarySerializer

      public SBinarySerializer()
  • Method Details

    • writeObjectToByteArray

      public static byte[] writeObjectToByteArray(Object val, ClassLoader classloader)
      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

      public static long writeObjectToStream(OutputStream os, Object val, ClassLoader classloader)
      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

      public static byte[] writeObjectToFramedArray(Object val, ClassLoader classloader)
      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

      public static long writeObjectToDataOutput(DataOutput dato, Object val, ClassLoader classloader)
      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

      public static Object readObjectFromStream(InputStream is, ClassLoader classloader)
      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

      public static Object decodeObject(IDecodingContext context)
      Helper method for decoding an object (used for recursion).
      Parameters:
      context - The decoding context.
      Returns:
      Decoded object.
    • decodeRawObject

      protected static Object decodeRawObject(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.