Package jadex.binary

Class AbstractDecodingContext

    • Field Detail

      • classloader

        protected java.lang.ClassLoader classloader
        The classloader
      • decoderhandlers

        protected java.util.List<IDecoderHandler> decoderhandlers
        The decoder handlers.
      • stringpool

        protected java.util.List<java.lang.String> stringpool
        The String pool.
      • classnamepool

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

        protected java.lang.Object usercontext
        A user context.
      • postprocessors

        protected java.util.List<ITraverseProcessor> postprocessors
        The postprocessors.
      • lastobject

        protected java.lang.Object lastobject
        The last decoded object
      • currentclassname

        protected java.lang.String currentclassname
        The current class name.
      • errorreporter

        protected IErrorReporter errorreporter
        Error Reporter
      • knownobjects

        protected BiHashMap<java.lang.Long,​java.lang.Object> knownobjects
    • Method Detail

      • getClassloader

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

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

        public java.lang.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,
                                   java.lang.Object object)
        Sets a known object by ID.
        Specified by:
        setObjectForId in interface IDecodingContext
        Parameters:
        id - The ID.
        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 IDecodingContext
        Parameters:
        object - The object
        Returns:
        The ID.
      • getUserContext

        public java.lang.Object getUserContext()
        Returns the user context.
        Specified by:
        getUserContext in interface IUserContextContainer
        Returns:
        The user context.
      • getLastObject

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

        public void setLastObject​(java.lang.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 java.lang.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 java.lang.String readClassname()
        Helper method for decoding a class name.
        Specified by:
        readClassname in interface IDecodingContext
        Returns:
        String encoded at the current position.
      • pooledRead

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

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

        protected void setCurrentClassName​(java.lang.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.