Package jadex.binary

Class AbstractCodec

    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractCodec()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canReference​(java.lang.Object object, java.lang.Class<?> clazz, IEncodingContext ec)
      Test if the codec allows referencing.
      abstract java.lang.Object createObject​(java.lang.Class<?> clazz, IDecodingContext context)
      Creates the object during decoding.
      java.lang.Object decode​(java.lang.Class<?> clazz, IDecodingContext context)
      Decodes an object.
      java.lang.Object decodeSubObjects​(java.lang.Object object, java.lang.Class<?> clazz, IDecodingContext context)
      Decodes and adds sub-objects during decoding.
      abstract java.lang.Object encode​(java.lang.Object object, java.lang.Class<?> clazz, java.util.List<ITraverseProcessor> preprocessors, java.util.List<ITraverseProcessor> processors, Traverser.MODE mode, Traverser traverser, java.lang.ClassLoader targetcl, IEncodingContext ec)
      Encode the object.
      abstract boolean isApplicable​(java.lang.Class<?> clazz)
      Tests if the decoder can decode the class.
      boolean isApplicable​(java.lang.Object object, java.lang.reflect.Type type, java.lang.ClassLoader targetcl, java.lang.Object context)
      Test if the processor is applicable.
      protected boolean isFixedFrame()
      Declares if the codec should use fixed or variable framing in framing mode.
      java.lang.Object process​(java.lang.Object object, java.lang.reflect.Type type, Traverser traverser, java.util.List<ITraverseProcessor> conversionprocessors, java.util.List<ITraverseProcessor> processors, Traverser.MODE mode, java.lang.ClassLoader targetcl, java.lang.Object context)
      Process an object.
      void recordKnownDecodedObject​(java.lang.Object object, IDecodingContext context)
      Record object as known during decoding, allows different behavior if needed.
      • Methods inherited from class java.lang.Object

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

      • AbstractCodec

        public AbstractCodec()
    • Method Detail

      • process

        public java.lang.Object process​(java.lang.Object object,
                                        java.lang.reflect.Type type,
                                        Traverser traverser,
                                        java.util.List<ITraverseProcessor> conversionprocessors,
                                        java.util.List<ITraverseProcessor> processors,
                                        Traverser.MODE mode,
                                        java.lang.ClassLoader targetcl,
                                        java.lang.Object context)
        Process an object.
        Specified by:
        process in interface ITraverseProcessor
        Parameters:
        object - The object.
        targetcl - If not null, the traverser should make sure that the result object is compatible with the class loader, e.g. by cloning the object using the class loaded from the target class loader.
        Returns:
        The processed object.
      • canReference

        public boolean canReference​(java.lang.Object object,
                                    java.lang.Class<?> clazz,
                                    IEncodingContext ec)
        Test if the codec allows referencing.
        Parameters:
        object - The object.
        clazz - The class.
        ec - The encoding context.
        Returns:
        True, if the codec allows referencing.
      • decode

        public java.lang.Object decode​(java.lang.Class<?> clazz,
                                       IDecodingContext context)
        Decodes an object.
        Specified by:
        decode in interface IDecoderHandler
        Parameters:
        clazz - The class of the object.
        context - The decoding context.
        Returns:
        The decoded object.
      • createObject

        public abstract java.lang.Object createObject​(java.lang.Class<?> clazz,
                                                      IDecodingContext context)
        Creates the object during decoding.
        Parameters:
        clazz - The class of the object.
        context - The decoding context.
        Returns:
        The created object.
      • recordKnownDecodedObject

        public void recordKnownDecodedObject​(java.lang.Object object,
                                             IDecodingContext context)
        Record object as known during decoding, allows different behavior if needed.
      • decodeSubObjects

        public java.lang.Object decodeSubObjects​(java.lang.Object object,
                                                 java.lang.Class<?> clazz,
                                                 IDecodingContext context)
        Decodes and adds sub-objects during decoding.
        Parameters:
        object - The instantiated object.
        clazz - The class of the object.
        context - The decoding context.
        Returns:
        The finished object.
      • isApplicable

        public boolean isApplicable​(java.lang.Object object,
                                    java.lang.reflect.Type type,
                                    java.lang.ClassLoader targetcl,
                                    java.lang.Object context)
        Test if the processor is applicable.
        Specified by:
        isApplicable in interface ITraverseProcessor
        Parameters:
        object - The object.
        targetcl - If not null, the traverser should make sure that the result object is compatible with the class loader, e.g. by cloning the object using the class loaded from the target class loader.
        Returns:
        True, if is applicable.
      • isApplicable

        public abstract boolean isApplicable​(java.lang.Class<?> clazz)
        Tests if the decoder can decode the class.
        Specified by:
        isApplicable in interface IDecoderHandler
        Parameters:
        clazz - The class.
        Returns:
        True, if the decoder can decode this class.
      • isFixedFrame

        protected boolean isFixedFrame()
        Declares if the codec should use fixed or variable framing in framing mode. Variable framing tends to be more space-efficient especially for small object but can be more costly to encode when the object is larger than 127 bytes. Addendum: Testing seems to suggest that the performance impact is below measuring noise, therefore variable-size framing is now enabled for all codecs. Default is false (variable encoding).
        Returns:
        True, if fixed size framing should be used.