Package jadex.binary

Class AbstractEncodingContext

java.lang.Object
jadex.binary.AbstractEncodingContext
All Implemented Interfaces:
IEncodingContext, jadex.common.transformation.traverser.IRootObjectContext, jadex.common.transformation.traverser.IUserContextContainer
Direct Known Subclasses:
DataOutputEncodingContext, EncodingContext, FramingEncodingContext

public abstract class AbstractEncodingContext extends Object implements IEncodingContext
Abstract encoding context that provides base functionality.
  • Field Details

    • knownobjects

      protected Map<Object,Long> knownobjects
      Map with known objects and their IDs
    • lastinputobject

      protected Object lastinputobject
      The last input object.
    • preprocessors

      protected List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors
      The preprocessors.
    • classloader

      protected ClassLoader classloader
      The classloader
    • rootobject

      protected Object rootobject
      The root object.
    • usercontext

      protected Object usercontext
      A user context.
    • ignorewriteclass

      protected boolean ignorewriteclass
      Flag indicating class names should not be written (can be temporarily disabled for one write).
    • nonanonclasscache

      protected Set<Class<?>> nonanonclasscache
      The cache for non-inner classes.
    • stringpool

      protected Map<String,Integer> stringpool
      The string pool.
    • classidcache

      protected Map<Class<?>,Integer> classidcache
      Cache for class IDs.
    • classnamepool

      protected Map<String,Integer> classnamepool
      The class name pool.
    • writtenbytes

      protected long writtenbytes
      The bytes written to the output.
  • Constructor Details

    • AbstractEncodingContext

      public AbstractEncodingContext(Object rootobject, Object usercontext, List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors, ClassLoader classloader, SerializationConfig config)
  • Method Details

    • getPreprocessors

      public List<jadex.common.transformation.traverser.ITraverseProcessor> getPreprocessors()
      Returns the preprocessors.
      Specified by:
      getPreprocessors in interface IEncodingContext
      Returns:
      The preprocessors
    • getClassLoader

      public ClassLoader getClassLoader()
      Gets the classloader.
      Specified by:
      getClassLoader in interface IEncodingContext
      Returns:
      The classloader.
    • getRootObject

      public Object getRootObject()
      Get the rootobject.
      Specified by:
      getRootObject in interface jadex.common.transformation.traverser.IRootObjectContext
      Returns:
      the rootobject.
    • getWrittenBytes

      public long getWrittenBytes()
      Returns the number of bytes written.
      Specified by:
      getWrittenBytes in interface IEncodingContext
      Returns:
      The number of bytes written.
    • getUserContext

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

      public Set<Class<?>> getNonInnerClassCache()
      Returns the non-inner class cache.
      Specified by:
      getNonInnerClassCache in interface IEncodingContext
      Returns:
      The non-inner class cache.
    • createObjectId

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

      public void setInputObject(Object object)
      Sets the object for which the next createObjectId() call creates an ID.
      Specified by:
      setInputObject in interface IEncodingContext
      Parameters:
      object - The object.
    • getObjectId

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

      public void setIgnoreNextClassWrite(boolean state)
      Puts the context in a state where the next call to writeClass is ignored.
      Specified by:
      setIgnoreNextClassWrite in interface IEncodingContext
      Parameters:
      state - If true, the next class write will be ignored and the state reset.
    • isIgnoreNextClassWrite

      protected boolean isIgnoreNextClassWrite()
    • writeVarInt

      public void writeVarInt(long value)
      Writes a VarInt.
      Specified by:
      writeVarInt in interface IEncodingContext
      Parameters:
      value - Value being written.
    • writeSignedVarInt

      public void writeSignedVarInt(long value)
      Writes a signed VarInt.
      Specified by:
      writeSignedVarInt in interface IEncodingContext
      Parameters:
      value - Value being written.
    • writeString

      public void writeString(String string)
      Description copied from interface: IEncodingContext
      Writes a string to the context.
      Specified by:
      writeString in interface IEncodingContext
      Parameters:
      string -
    • writeClass

      public void writeClass(Class<?> clazz)
      Description copied from interface: IEncodingContext
      Writes a class to the context.
      Specified by:
      writeClass in interface IEncodingContext
      Parameters:
      clazz -
    • writeClassname

      public int writeClassname(String name)
      Description copied from interface: IEncodingContext
      Writes the name of a class.
      Specified by:
      writeClassname in interface IEncodingContext
      Parameters:
      name - The name of the class.
    • writeBoolean

      public void writeBoolean(boolean bool)
      Writes a boolean.
      Specified by:
      writeBoolean in interface IEncodingContext
      Parameters:
      bool - The boolean.
    • startObjectFrame

      public void startObjectFrame()
      Starts an object frame when using a context with framing support.
      Specified by:
      startObjectFrame in interface IEncodingContext
    • startObjectFrame

      public void startObjectFrame(boolean fixedsize)
      Starts an object frame when using a context with framing support.
      Specified by:
      startObjectFrame in interface IEncodingContext
      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 IEncodingContext
    • pooledWrite

      protected void pooledWrite(Map<String,Integer> pool, String string)
      Writes a string using a pool.
      Parameters:
      string -