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 interface
Interface for versioned operations.protected class
Operations for format version 2.protected class
Operations for format version 3.protected class
Operations for format version 4. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ClassLoader
The classloaderThe class name pool.protected SerializationConfig
The serialization config.protected String
The current class name.protected List
<IDecoderHandler> The decoder handlers.protected jadex.common.transformation.traverser.IErrorReporter
Error Reporterprotected Object
The last decoded objectprotected List
<jadex.common.transformation.traverser.ITraverseProcessor> The postprocessors.The String pool.protected Object
A 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 TypeMethodDescriptionlong
createObjectId
(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.IErrorReporter
Gets 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.boolean
Reads a boolean value from the buffer.Helper method for decoding a class name.long
Helper method for decoding a signed variable-sized integer (VarInt).Helper method for decoding a string.long
Helper method for decoding a variable-sized integer (VarInt).protected void
setCurrentClassName
(String currentclassname) Sets the current class name.void
setLastObject
(Object lastobject) Sets the last object decoded.void
setObjectForId
(long id, Object object) Sets a known object by ID.void
setVersion
(int version) Sets the format version.void
Starts an object frame when using a context with framing support.void
startObjectFrame
(boolean fixedsize) Starts an object frame when using a context with framing support.void
Stops 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, wait
Methods 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:
getClassloader
in interfaceIDecodingContext
- Returns:
- The classloader.
-
getDecoderHandlers
Returns the handlers used to decode objects.- Specified by:
getDecoderHandlers
in interfaceIDecodingContext
- Returns:
- The handlers.
-
getPostProcessors
Returns the handlers used for post-processing.- Specified by:
getPostProcessors
in interfaceIDecodingContext
- Returns:
- Post-processing handlers.
-
createObjectId
Creates ID for an object.- Specified by:
createObjectId
in interfaceIDecodingContext
- Parameters:
object
- The object- Returns:
- The ID.
-
getObjectForId
Gets a known object by ID.- Specified by:
getObjectForId
in interfaceIDecodingContext
- Parameters:
id
- The ID.- Returns:
- The object or null.
-
setObjectForId
Sets a known object by ID.- Specified by:
setObjectForId
in interfaceIDecodingContext
- Parameters:
id
- The ID.object
- The object..
-
getObjectId
Gets the ID of a known object.- Specified by:
getObjectId
in interfaceIDecodingContext
- Parameters:
object
- The object- Returns:
- The ID.
-
getUserContext
Returns the user context.- Specified by:
getUserContext
in interfacejadex.common.transformation.traverser.IUserContextContainer
- Returns:
- The user context.
-
getErrorReporter
public jadex.common.transformation.traverser.IErrorReporter getErrorReporter()Gets the error reporter.- Specified by:
getErrorReporter
in interfaceIDecodingContext
- Returns:
- The error reporter.
-
getLastObject
Returns the last object decoded.- Specified by:
getLastObject
in interfaceIDecodingContext
- Returns:
- The last object decoded.
-
setLastObject
Sets the last object decoded.- Specified by:
setLastObject
in interfaceIDecodingContext
- Parameters:
lastobject
- The last object decoded.
-
readBoolean
public boolean readBoolean()Reads a boolean value from the buffer.- Specified by:
readBoolean
in interfaceIDecodingContext
- Returns:
- Boolean value.
-
readString
Helper method for decoding a string.- Specified by:
readString
in interfaceIDecodingContext
- Returns:
- String encoded at the current position.
-
readVarInt
public long readVarInt()Helper method for decoding a variable-sized integer (VarInt).- Specified by:
readVarInt
in interfaceIDecodingContext
- Returns:
- The decoded value.
-
readSignedVarInt
public long readSignedVarInt()Helper method for decoding a signed variable-sized integer (VarInt).- Specified by:
readSignedVarInt
in interfaceIDecodingContext
- Returns:
- The decoded value.
-
readClassname
Helper method for decoding a class name.- Specified by:
readClassname
in 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:
getCurrentClassName
in interfaceIDecodingContext
- Returns:
- The current class name.
-
setCurrentClassName
Sets the current class name. -
setVersion
public void setVersion(int version) Sets the format version.- Specified by:
setVersion
in 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:
startObjectFrame
in 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:
stopObjectFrame
in 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:
read
in 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.
-