Package jadex.binary
Class AbstractEncodingContext
java.lang.Object
jadex.binary.AbstractEncodingContext
- All Implemented Interfaces:
IEncodingContext,jadex.common.transformation.traverser.IRootObjectContext,jadex.common.transformation.traverser.IUserContextContainer
- Direct Known Subclasses:
DataOutputEncodingContext,EncodingContext,FramingEncodingContext
Abstract encoding context that provides base functionality.
-
Field Summary
FieldsModifier and TypeFieldDescriptionCache for class IDs.protected ClassLoaderThe classloaderThe class name pool.protected booleanFlag indicating class names should not be written (can be temporarily disabled for one write).Map with known objects and their IDsprotected ObjectThe last input object.The cache for non-inner classes.protected List<jadex.common.transformation.traverser.ITraverseProcessor>The preprocessors.protected ObjectThe root object.The string pool.protected ObjectA user context.protected longThe bytes written to the output. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractEncodingContext(Object rootobject, Object usercontext, List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors, ClassLoader classloader, SerializationConfig config) -
Method Summary
Modifier and TypeMethodDescriptionlongCreates ID for an object.Gets the classloader.Returns the non-inner class cache.getObjectId(Object object) Gets the ID of a known object.List<jadex.common.transformation.traverser.ITraverseProcessor>Returns the preprocessors.Get the rootobject.Returns the user context.longReturns the number of bytes written.protected booleanprotected voidpooledWrite(Map<String, Integer> pool, String string) Writes a string using a pool.voidsetIgnoreNextClassWrite(boolean state) Puts the context in a state where the next call to writeClass is ignored.voidsetInputObject(Object object) Sets the object for which the next createObjectId() call creates an ID.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.voidwriteBoolean(boolean bool) Writes a boolean.voidwriteClass(Class<?> clazz) Writes a class to the context.intwriteClassname(String name) Writes the name of a class.voidwriteSignedVarInt(long value) Writes a signed VarInt.voidwriteString(String string) Writes a string to the context.voidwriteVarInt(long value) Writes a VarInt.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jadex.binary.IEncodingContext
write, writeByte
-
Field Details
-
knownobjects
Map with known objects and their IDs -
lastinputobject
The last input object. -
preprocessors
The preprocessors. -
classloader
The classloader -
rootobject
The root object. -
usercontext
A user context. -
ignorewriteclass
protected boolean ignorewriteclassFlag indicating class names should not be written (can be temporarily disabled for one write). -
nonanonclasscache
The cache for non-inner classes. -
stringpool
The string pool. -
classidcache
Cache for class IDs. -
classnamepool
The class name pool. -
writtenbytes
protected long writtenbytesThe bytes written to the output.
-
-
Constructor Details
-
AbstractEncodingContext
public AbstractEncodingContext(Object rootobject, Object usercontext, List<jadex.common.transformation.traverser.ITraverseProcessor> preprocessors, ClassLoader classloader, SerializationConfig config)
-
-
Method Details
-
getPreprocessors
Returns the preprocessors.- Specified by:
getPreprocessorsin interfaceIEncodingContext- Returns:
- The preprocessors
-
getClassLoader
Gets the classloader.- Specified by:
getClassLoaderin interfaceIEncodingContext- Returns:
- The classloader.
-
getRootObject
Get the rootobject.- Specified by:
getRootObjectin interfacejadex.common.transformation.traverser.IRootObjectContext- Returns:
- the rootobject.
-
getWrittenBytes
public long getWrittenBytes()Returns the number of bytes written.- Specified by:
getWrittenBytesin interfaceIEncodingContext- Returns:
- The number of bytes written.
-
getUserContext
Returns the user context.- Specified by:
getUserContextin interfacejadex.common.transformation.traverser.IUserContextContainer- Returns:
- The user context.
-
getNonInnerClassCache
Returns the non-inner class cache.- Specified by:
getNonInnerClassCachein interfaceIEncodingContext- Returns:
- The non-inner class cache.
-
createObjectId
public long createObjectId()Creates ID for an object.- Specified by:
createObjectIdin interfaceIEncodingContext- Parameters:
object- The object- Returns:
- The ID.
-
setInputObject
Sets the object for which the next createObjectId() call creates an ID.- Specified by:
setInputObjectin interfaceIEncodingContext- Parameters:
object- The object.
-
getObjectId
Gets the ID of a known object.- Specified by:
getObjectIdin interfaceIEncodingContext- Parameters:
object- The object- Returns:
- The ID.
-
setIgnoreNextClassWrite
public void setIgnoreNextClassWrite(boolean state) Puts the context in a state where the next call to writeClass is ignored.- Specified by:
setIgnoreNextClassWritein interfaceIEncodingContext- Parameters:
state- If true, the next class write will be ignored and the state reset.
-
isIgnoreNextClassWrite
protected boolean isIgnoreNextClassWrite() -
writeVarInt
public void writeVarInt(long value) Writes a VarInt.- Specified by:
writeVarIntin interfaceIEncodingContext- Parameters:
value- Value being written.
-
writeSignedVarInt
public void writeSignedVarInt(long value) Writes a signed VarInt.- Specified by:
writeSignedVarIntin interfaceIEncodingContext- Parameters:
value- Value being written.
-
writeString
Description copied from interface:IEncodingContextWrites a string to the context.- Specified by:
writeStringin interfaceIEncodingContext- Parameters:
string-
-
writeClass
Description copied from interface:IEncodingContextWrites a class to the context.- Specified by:
writeClassin interfaceIEncodingContext- Parameters:
clazz-
-
writeClassname
Description copied from interface:IEncodingContextWrites the name of a class.- Specified by:
writeClassnamein interfaceIEncodingContext- Parameters:
name- The name of the class.
-
writeBoolean
public void writeBoolean(boolean bool) Writes a boolean.- Specified by:
writeBooleanin interfaceIEncodingContext- Parameters:
bool- The boolean.
-
startObjectFrame
public void startObjectFrame()Starts an object frame when using a context with framing support.- Specified by:
startObjectFramein interfaceIEncodingContext
-
startObjectFrame
public void startObjectFrame(boolean fixedsize) Starts an object frame when using a context with framing support.- Specified by:
startObjectFramein interfaceIEncodingContext- 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 interfaceIEncodingContext
-
pooledWrite
Writes a string using a pool.- Parameters:
string-
-