Package jadex.binary
Class AbstractDecodingContext
java.lang.Object
jadex.binary.AbstractDecodingContext
- All Implemented Interfaces:
IDecodingContext,jadex.common.transformation.traverser.IUserContextContainer
- Direct Known Subclasses:
DataInputDecodingContext,StreamDecodingContext
Abstract base class for decoding context.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceInterface for versioned operations.protected classOperations for format version 2.protected classOperations for format version 3.protected classOperations for format version 4. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ClassLoaderThe classloaderThe class name pool.protected SerializationConfigThe serialization config.protected StringThe current class name.protected List<IDecoderHandler>The decoder handlers.protected jadex.common.transformation.traverser.IErrorReporterError Reporterprotected ObjectThe last decoded objectprotected List<jadex.common.transformation.traverser.ITraverseProcessor>The postprocessors.The String pool.protected ObjectA user context.Handler for versioned operations. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDecodingContext(List<IDecoderHandler> decoderhandlers, List<jadex.common.transformation.traverser.ITraverseProcessor> postprocessors, Object usercontext, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter errorreporter, SerializationConfig config) Initializes the context. -
Method Summary
Modifier and TypeMethodDescriptionlongcreateObjectId(Object object) Creates ID for an object.Gets the classloader.Gets the current class name.Returns the handlers used to decode objects.jadex.common.transformation.traverser.IErrorReporterGets the error reporter.Returns the last object decoded.getObjectForId(long id) Gets a known object by ID.getObjectId(Object object) Gets the ID of a known object.List<jadex.common.transformation.traverser.ITraverseProcessor>Returns the handlers used for post-processing.Returns the user context.pooledRead(List<String> pool) Readsa a string using a pool.abstract byte[]read(byte[] array) Reads a number of bytes from the buffer and fills the array.abstract byte[]read(byte[] array, int woffset, int wlength) Reads a number of bytes from the buffer and fills the array.abstract byte[]read(int count) Reads a number of bytes from the buffer.booleanReads a boolean value from the buffer.Helper method for decoding a class name.longHelper method for decoding a signed variable-sized integer (VarInt).Helper method for decoding a string.longHelper method for decoding a variable-sized integer (VarInt).protected voidsetCurrentClassName(String currentclassname) Sets the current class name.voidsetLastObject(Object lastobject) Sets the last object decoded.voidsetObjectForId(long id, Object object) Sets a known object by ID.voidsetVersion(int version) Sets the format version.voidStarts an object frame when using a context with framing support.voidstartObjectFrame(boolean fixedsize) Starts an object frame when using a context with framing support.voidStops an object frame when using a context with framing support.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jadex.binary.IDecodingContext
getCurrentOffset, readByte
-
Field Details
-
classloader
The classloader -
decoderhandlers
The decoder handlers. -
versionedhandler
Handler for versioned operations. -
stringpool
The String pool. -
classnamepool
The class name pool. -
usercontext
A user context. -
postprocessors
The postprocessors. -
lastobject
The last decoded object -
currentclassname
The current class name. -
errorreporter
protected jadex.common.transformation.traverser.IErrorReporter errorreporterError Reporter -
knownobjects
-
config
The serialization config.
-
-
Constructor Details
-
AbstractDecodingContext
public AbstractDecodingContext(List<IDecoderHandler> decoderhandlers, List<jadex.common.transformation.traverser.ITraverseProcessor> postprocessors, Object usercontext, ClassLoader classloader, jadex.common.transformation.traverser.IErrorReporter errorreporter, SerializationConfig config) Initializes the context.
-
-
Method Details
-
getClassloader
Gets the classloader.- Specified by:
getClassloaderin interfaceIDecodingContext- Returns:
- The classloader.
-
getDecoderHandlers
Returns the handlers used to decode objects.- Specified by:
getDecoderHandlersin interfaceIDecodingContext- Returns:
- The handlers.
-
getPostProcessors
Returns the handlers used for post-processing.- Specified by:
getPostProcessorsin interfaceIDecodingContext- Returns:
- Post-processing handlers.
-
createObjectId
Creates ID for an object.- Specified by:
createObjectIdin interfaceIDecodingContext- Parameters:
object- The object- Returns:
- The ID.
-
getObjectForId
Gets a known object by ID.- Specified by:
getObjectForIdin interfaceIDecodingContext- Parameters:
id- The ID.- Returns:
- The object or null.
-
setObjectForId
Sets a known object by ID.- Specified by:
setObjectForIdin interfaceIDecodingContext- Parameters:
id- The ID.object- The object..
-
getObjectId
Gets the ID of a known object.- Specified by:
getObjectIdin interfaceIDecodingContext- Parameters:
object- The object- Returns:
- The ID.
-
getUserContext
Returns the user context.- Specified by:
getUserContextin interfacejadex.common.transformation.traverser.IUserContextContainer- Returns:
- The user context.
-
getErrorReporter
public jadex.common.transformation.traverser.IErrorReporter getErrorReporter()Gets the error reporter.- Specified by:
getErrorReporterin interfaceIDecodingContext- Returns:
- The error reporter.
-
getLastObject
Returns the last object decoded.- Specified by:
getLastObjectin interfaceIDecodingContext- Returns:
- The last object decoded.
-
setLastObject
Sets the last object decoded.- Specified by:
setLastObjectin interfaceIDecodingContext- Parameters:
lastobject- The last object decoded.
-
readBoolean
public boolean readBoolean()Reads a boolean value from the buffer.- Specified by:
readBooleanin interfaceIDecodingContext- Returns:
- Boolean value.
-
readString
Helper method for decoding a string.- Specified by:
readStringin interfaceIDecodingContext- Returns:
- String encoded at the current position.
-
readVarInt
public long readVarInt()Helper method for decoding a variable-sized integer (VarInt).- Specified by:
readVarIntin interfaceIDecodingContext- Returns:
- The decoded value.
-
readSignedVarInt
public long readSignedVarInt()Helper method for decoding a signed variable-sized integer (VarInt).- Specified by:
readSignedVarIntin interfaceIDecodingContext- Returns:
- The decoded value.
-
readClassname
Helper method for decoding a class name.- Specified by:
readClassnamein interfaceIDecodingContext- Returns:
- String encoded at the current position.
-
pooledRead
Readsa a string using a pool.- Parameters:
pool- The pool.- Returns:
- The string.
-
getCurrentClassName
Gets the current class name.- Specified by:
getCurrentClassNamein interfaceIDecodingContext- Returns:
- The current class name.
-
setCurrentClassName
Sets the current class name. -
setVersion
public void setVersion(int version) Sets the format version.- Specified by:
setVersionin interfaceIDecodingContext- 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:
startObjectFramein interfaceIDecodingContext- 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:
stopObjectFramein interfaceIDecodingContext
-
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:
readin interfaceIDecodingContext- 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.
-