Package jadex.binary

Class AbstractEncodingContext

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.Class<?>,​java.lang.Integer> classidcache
      Cache for class IDs.
      protected java.lang.ClassLoader classloader
      The classloader
      protected java.util.Map<java.lang.String,​java.lang.Integer> classnamepool
      The class name pool.
      protected boolean ignorewriteclass
      Flag indicating class names should not be written (can be temporarily disabled for one write).
      protected java.util.Map<java.lang.Object,​java.lang.Long> knownobjects
      Map with known objects and their IDs
      protected java.lang.Object lastinputobject
      The last input object.
      protected java.util.Set<java.lang.Class<?>> nonanonclasscache
      The cache for non-inner classes.
      protected java.util.List<ITraverseProcessor> preprocessors
      The preprocessors.
      protected java.lang.Object rootobject
      The root object.
      protected java.util.Map<java.lang.String,​java.lang.Integer> stringpool
      The string pool.
      protected java.lang.Object usercontext
      A user context.
      protected long writtenbytes
      The bytes written to the output.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long createObjectId()
      Creates ID for an object.
      java.lang.ClassLoader getClassLoader()
      Gets the classloader.
      java.util.Set<java.lang.Class<?>> getNonInnerClassCache()
      Returns the non-inner class cache.
      java.lang.Long getObjectId​(java.lang.Object object)
      Gets the ID of a known object.
      java.util.List<ITraverseProcessor> getPreprocessors()
      Returns the preprocessors.
      java.lang.Object getRootObject()
      Get the rootobject.
      java.lang.Object getUserContext()
      Returns the user context.
      long getWrittenBytes()
      Returns the number of bytes written.
      protected boolean isIgnoreNextClassWrite()  
      protected void pooledWrite​(java.util.Map<java.lang.String,​java.lang.Integer> pool, java.lang.String string)
      Writes a string using a pool.
      void setIgnoreNextClassWrite​(boolean state)
      Puts the context in a state where the next call to writeClass is ignored.
      void setInputObject​(java.lang.Object object)
      Sets the object for which the next createObjectId() call creates an ID.
      void startObjectFrame()
      Starts an object frame when using a context with framing support.
      void startObjectFrame​(boolean fixedsize)
      Starts an object frame when using a context with framing support.
      void stopObjectFrame()
      Stops an object frame when using a context with framing support.
      void writeBoolean​(boolean bool)
      Writes a boolean.
      void writeClass​(java.lang.Class<?> clazz)
      Writes a class to the context.
      int writeClassname​(java.lang.String name)
      Writes the name of a class.
      void writeSignedVarInt​(long value)
      Writes a signed VarInt.
      void writeString​(java.lang.String string)
      Writes a string to the context.
      void writeVarInt​(long value)
      Writes a VarInt.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • knownobjects

        protected java.util.Map<java.lang.Object,​java.lang.Long> knownobjects
        Map with known objects and their IDs
      • lastinputobject

        protected java.lang.Object lastinputobject
        The last input object.
      • preprocessors

        protected java.util.List<ITraverseProcessor> preprocessors
        The preprocessors.
      • classloader

        protected java.lang.ClassLoader classloader
        The classloader
      • rootobject

        protected java.lang.Object rootobject
        The root object.
      • usercontext

        protected java.lang.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 java.util.Set<java.lang.Class<?>> nonanonclasscache
        The cache for non-inner classes.
      • stringpool

        protected java.util.Map<java.lang.String,​java.lang.Integer> stringpool
        The string pool.
      • classidcache

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

        protected java.util.Map<java.lang.String,​java.lang.Integer> classnamepool
        The class name pool.
      • writtenbytes

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

      • AbstractEncodingContext

        public AbstractEncodingContext​(java.lang.Object rootobject,
                                       java.lang.Object usercontext,
                                       java.util.List<ITraverseProcessor> preprocessors,
                                       java.lang.ClassLoader classloader,
                                       SerializationConfig config)
    • Method Detail

      • getClassLoader

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

        public java.lang.Object getRootObject()
        Get the rootobject.
        Specified by:
        getRootObject in interface 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 java.lang.Object getUserContext()
        Returns the user context.
        Specified by:
        getUserContext in interface IUserContextContainer
        Returns:
        The user context.
      • getNonInnerClassCache

        public java.util.Set<java.lang.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​(java.lang.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 java.lang.Long getObjectId​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.util.Map<java.lang.String,​java.lang.Integer> pool,
                                   java.lang.String string)
        Writes a string using a pool.
        Parameters:
        string -