Package jadex.binary

Class AbstractCodec

java.lang.Object
jadex.binary.AbstractCodec
All Implemented Interfaces:
IDecoderHandler, jadex.common.transformation.traverser.ITraverseProcessor
Direct Known Subclasses:
ArrayCodec, BeanCodec, BigIntegerCodec, CalendarCodec, CertificateCodec, ClassCodec, CollectionCodec, ColorCodec, CurrencyCodec, DateCodec, EnumCodec, EnumerationCodec, ImageCodec, InetAddressCodec, LocalDateTimeCodec, LoggingLevelCodec, LogRecordCodec, LRUCodec, MapCodec, MultiCollectionCodec, NumberCodec, OptionalCodec, RectangleCodec, StackTraceElementCodec, StringCodec, ThrowableCodec, TimestampCodec, TupleCodec, URICodec, URLCodec, UUIDCodec

public abstract class AbstractCodec extends Object implements jadex.common.transformation.traverser.ITraverseProcessor, IDecoderHandler
  • Constructor Details

    • AbstractCodec

      public AbstractCodec()
  • Method Details

    • process

      public Object process(Object object, Type type, jadex.common.transformation.traverser.Traverser traverser, List<jadex.common.transformation.traverser.ITraverseProcessor> conversionprocessors, List<jadex.common.transformation.traverser.ITraverseProcessor> processors, jadex.common.transformation.IStringConverter converter, jadex.common.transformation.traverser.Traverser.MODE mode, ClassLoader targetcl, Object context)
      Process an object.
      Specified by:
      process in interface jadex.common.transformation.traverser.ITraverseProcessor
      Parameters:
      object - The object.
      Returns:
      The processed object.
    • canReference

      public boolean canReference(Object object, 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.
    • encode

      public abstract Object encode(Object object, Class<?> clazz, List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors, List<jadex.common.transformation.traverser.ITraverseProcessor> processors, jadex.common.transformation.IStringConverter converter, jadex.common.transformation.traverser.Traverser.MODE mode, jadex.common.transformation.traverser.Traverser traverser, ClassLoader targetcl, IEncodingContext ec)
      Encode the object.
    • decode

      public Object decode(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 Object createObject(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(Object object, IDecodingContext context)
      Record object as known during decoding, allows different behavior if needed.
    • decodeSubObjects

      public Object decodeSubObjects(Object object, 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(Object object, Type type, ClassLoader targetcl, Object context)
      Test if the processor is applicable.
      Specified by:
      isApplicable in interface jadex.common.transformation.traverser.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(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.