Package jadex.binary
Class AbstractCodec
- java.lang.Object
-
- jadex.binary.AbstractCodec
-
- All Implemented Interfaces:
IDecoderHandler,ITraverseProcessor
- Direct Known Subclasses:
ArrayCodec,BeanCodec,BigIntegerCodec,BinaryResponseProcessor,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 java.lang.Object implements ITraverseProcessor, IDecoderHandler
-
-
Constructor Summary
Constructors Constructor Description AbstractCodec()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancanReference(java.lang.Object object, java.lang.Class<?> clazz, IEncodingContext ec)Test if the codec allows referencing.abstract java.lang.ObjectcreateObject(java.lang.Class<?> clazz, IDecodingContext context)Creates the object during decoding.java.lang.Objectdecode(java.lang.Class<?> clazz, IDecodingContext context)Decodes an object.java.lang.ObjectdecodeSubObjects(java.lang.Object object, java.lang.Class<?> clazz, IDecodingContext context)Decodes and adds sub-objects during decoding.abstract java.lang.Objectencode(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 booleanisApplicable(java.lang.Class<?> clazz)Tests if the decoder can decode the class.booleanisApplicable(java.lang.Object object, java.lang.reflect.Type type, java.lang.ClassLoader targetcl, java.lang.Object context)Test if the processor is applicable.protected booleanisFixedFrame()Declares if the codec should use fixed or variable framing in framing mode.java.lang.Objectprocess(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.voidrecordKnownDecodedObject(java.lang.Object object, IDecodingContext context)Record object as known during decoding, allows different behavior if needed.
-
-
-
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:
processin interfaceITraverseProcessor- 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.
-
encode
public 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.
-
decode
public java.lang.Object decode(java.lang.Class<?> clazz, IDecodingContext context)Decodes an object.- Specified by:
decodein interfaceIDecoderHandler- 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:
isApplicablein interfaceITraverseProcessor- 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:
isApplicablein interfaceIDecoderHandler- 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.
-
-