Package jadex.binary

Class AbstractDecodingContext

java.lang.Object
jadex.binary.AbstractDecodingContext
All Implemented Interfaces:
IDecodingContext, jadex.common.transformation.traverser.IUserContextContainer
Direct Known Subclasses:
DataInputDecodingContext, StreamDecodingContext

public abstract class AbstractDecodingContext extends Object implements IDecodingContext
Abstract base class for decoding context.
  • Field Details

    • classloader

      protected ClassLoader classloader
      The classloader
    • decoderhandlers

      protected List<IDecoderHandler> decoderhandlers
      The decoder handlers.
    • versionedhandler

      protected AbstractDecodingContext.IVersionedHandler versionedhandler
      Handler for versioned operations.
    • stringpool

      protected List<String> stringpool
      The String pool.
    • classnamepool

      protected List<String> classnamepool
      The class name pool.
    • usercontext

      protected Object usercontext
      A user context.
    • postprocessors

      protected List<jadex.common.transformation.traverser.ITraverseProcessor> postprocessors
      The postprocessors.
    • lastobject

      protected Object lastobject
      The last decoded object
    • currentclassname

      protected String currentclassname
      The current class name.
    • errorreporter

      protected jadex.common.transformation.traverser.IErrorReporter errorreporter
      Error Reporter
    • knownobjects

      protected jadex.collection.BiHashMap<Long,Object> knownobjects
    • config

      protected SerializationConfig config
      The serialization config.
  • Constructor Details

    • AbstractDecodingContext

      public AbstractDecodingContext(List<IDecoderHandler> decoderhandlers, List<jadex.common.transformation.traverser.ITraverseProcessor> postprocessors, Object usercontext, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter errorreporter, SerializationConfig config)
      Initializes the context.
  • Method Details

    • getClassloader

      public ClassLoader getClassloader()
      Gets the classloader.
      Specified by:
      getClassloader in interface IDecodingContext
      Returns:
      The classloader.
    • getDecoderHandlers

      public List<IDecoderHandler> getDecoderHandlers()
      Returns the handlers used to decode objects.
      Specified by:
      getDecoderHandlers in interface IDecodingContext
      Returns:
      The handlers.
    • getPostProcessors

      public List<jadex.common.transformation.traverser.ITraverseProcessor> getPostProcessors()
      Returns the handlers used for post-processing.
      Specified by:
      getPostProcessors in interface IDecodingContext
      Returns:
      Post-processing handlers.
    • createObjectId

      public long createObjectId(Object object)
      Creates ID for an object.
      Specified by:
      createObjectId in interface IDecodingContext
      Parameters:
      object - The object
      Returns:
      The ID.
    • getObjectForId

      public Object getObjectForId(long id)
      Gets a known object by ID.
      Specified by:
      getObjectForId in interface IDecodingContext
      Parameters:
      id - The ID.
      Returns:
      The object or null.
    • setObjectForId

      public void setObjectForId(long id, Object object)
      Sets a known object by ID.
      Specified by:
      setObjectForId in interface IDecodingContext
      Parameters:
      id - The ID.
      object - The object..
    • getObjectId

      public Long getObjectId(Object object)
      Gets the ID of a known object.
      Specified by:
      getObjectId in interface IDecodingContext
      Parameters:
      object - The object
      Returns:
      The ID.
    • getUserContext

      public Object getUserContext()
      Returns the user context.
      Specified by:
      getUserContext in interface jadex.common.transformation.traverser.IUserContextContainer
      Returns:
      The user context.
    • getErrorReporter

      public jadex.common.transformation.traverser.IErrorReporter getErrorReporter()
      Gets the error reporter.
      Specified by:
      getErrorReporter in interface IDecodingContext
      Returns:
      The error reporter.
    • getLastObject

      public Object getLastObject()
      Returns the last object decoded.
      Specified by:
      getLastObject in interface IDecodingContext
      Returns:
      The last object decoded.
    • setLastObject

      public void setLastObject(Object lastobject)
      Sets the last object decoded.
      Specified by:
      setLastObject in interface IDecodingContext
      Parameters:
      lastobject - The last object decoded.
    • readBoolean

      public boolean readBoolean()
      Reads a boolean value from the buffer.
      Specified by:
      readBoolean in interface IDecodingContext
      Returns:
      Boolean value.
    • readString

      public String readString()
      Helper method for decoding a string.
      Specified by:
      readString in interface IDecodingContext
      Returns:
      String encoded at the current position.
    • readVarInt

      public long readVarInt()
      Helper method for decoding a variable-sized integer (VarInt).
      Specified by:
      readVarInt in interface IDecodingContext
      Returns:
      The decoded value.
    • readSignedVarInt

      public long readSignedVarInt()
      Helper method for decoding a signed variable-sized integer (VarInt).
      Specified by:
      readSignedVarInt in interface IDecodingContext
      Returns:
      The decoded value.
    • readClassname

      public String readClassname()
      Helper method for decoding a class name.
      Specified by:
      readClassname in interface IDecodingContext
      Returns:
      String encoded at the current position.
    • pooledRead

      public String pooledRead(List<String> pool)
      Readsa a string using a pool.
      Parameters:
      pool - The pool.
      Returns:
      The string.
    • getCurrentClassName

      public String getCurrentClassName()
      Gets the current class name.
      Specified by:
      getCurrentClassName in interface IDecodingContext
      Returns:
      The current class name.
    • setCurrentClassName

      protected void setCurrentClassName(String currentclassname)
      Sets the current class name.
    • setVersion

      public void setVersion(int version)
      Sets the format version.
      Specified by:
      setVersion in interface IDecodingContext
      Parameters:
      version - The version.
    • startObjectFrame

      public void startObjectFrame()
      Starts an object frame when using a context with framing support.
    • startObjectFrame

      public void startObjectFrame(boolean fixedsize)
      Starts an object frame when using a context with framing support.
      Specified by:
      startObjectFrame in interface IDecodingContext
      Parameters:
      fixedsize - If true, use fixed-size (integer) framing. Set true if the object being framed is expected to be larger than 127 bytes (same type of object MUST use either fixed OR variable framing).
    • stopObjectFrame

      public void stopObjectFrame()
      Stops an object frame when using a context with framing support.
      Specified by:
      stopObjectFrame in interface IDecodingContext
    • read

      public abstract byte[] read(int count)
      Reads a number of bytes from the buffer.
      Parameters:
      count - Number of bytes.
      Returns:
      Byte array with the bytes.
    • read

      public abstract byte[] read(byte[] array)
      Reads a number of bytes from the buffer and fills the array.
      Specified by:
      read in interface IDecodingContext
      Parameters:
      array - The byte array.
      Returns:
      The byte array for convenience.
    • read

      public abstract byte[] read(byte[] array, int woffset, int wlength)
      Reads a number of bytes from the buffer and fills the array.
      Parameters:
      array - The byte array.
      woffset - write offset.
      wlength - length to read.
      Returns:
      The byte array for convenience.