Package jadex.binary
Class AbstractEncodingContext
- java.lang.Object
- 
- jadex.binary.AbstractEncodingContext
 
- 
- All Implemented Interfaces:
- IEncodingContext,- IRootObjectContext,- IUserContextContainer
 - Direct Known Subclasses:
- DataOutputEncodingContext,- EncodingContext,- FramingEncodingContext
 
 public abstract class AbstractEncodingContext extends java.lang.Object implements IEncodingContext Abstract encoding context that provides base functionality.
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.util.Map<java.lang.Class<?>,java.lang.Integer>classidcacheCache for class IDs.protected java.lang.ClassLoaderclassloaderThe classloaderprotected java.util.Map<java.lang.String,java.lang.Integer>classnamepoolThe class name pool.protected booleanignorewriteclassFlag indicating class names should not be written (can be temporarily disabled for one write).protected java.util.Map<java.lang.Object,java.lang.Long>knownobjectsMap with known objects and their IDsprotected java.lang.ObjectlastinputobjectThe last input object.protected java.util.Set<java.lang.Class<?>>nonanonclasscacheThe cache for non-inner classes.protected java.util.List<ITraverseProcessor>preprocessorsThe preprocessors.protected java.lang.ObjectrootobjectThe root object.protected java.util.Map<java.lang.String,java.lang.Integer>stringpoolThe string pool.protected java.lang.ObjectusercontextA user context.protected longwrittenbytesThe bytes written to the output.
 - 
Constructor SummaryConstructors Constructor Description AbstractEncodingContext(java.lang.Object rootobject, java.lang.Object usercontext, java.util.List<ITraverseProcessor> preprocessors, java.lang.ClassLoader classloader, SerializationConfig config)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description longcreateObjectId()Creates ID for an object.java.lang.ClassLoadergetClassLoader()Gets the classloader.java.util.Set<java.lang.Class<?>>getNonInnerClassCache()Returns the non-inner class cache.java.lang.LonggetObjectId(java.lang.Object object)Gets the ID of a known object.java.util.List<ITraverseProcessor>getPreprocessors()Returns the preprocessors.java.lang.ObjectgetRootObject()Get the rootobject.java.lang.ObjectgetUserContext()Returns the user context.longgetWrittenBytes()Returns the number of bytes written.protected booleanisIgnoreNextClassWrite()protected voidpooledWrite(java.util.Map<java.lang.String,java.lang.Integer> pool, java.lang.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(java.lang.Object object)Sets the object for which the next createObjectId() call creates an ID.voidstartObjectFrame()Starts an object frame when using a context with framing support.voidstartObjectFrame(boolean fixedsize)Starts an object frame when using a context with framing support.voidstopObjectFrame()Stops an object frame when using a context with framing support.voidwriteBoolean(boolean bool)Writes a boolean.voidwriteClass(java.lang.Class<?> clazz)Writes a class to the context.intwriteClassname(java.lang.String name)Writes the name of a class.voidwriteSignedVarInt(long value)Writes a signed VarInt.voidwriteString(java.lang.String string)Writes a string to the context.voidwriteVarInt(long value)Writes a VarInt.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface jadex.binary.IEncodingContextwrite, writeByte
 
- 
 
- 
- 
- 
Field Detail- 
knownobjectsprotected java.util.Map<java.lang.Object,java.lang.Long> knownobjects Map with known objects and their IDs
 - 
lastinputobjectprotected java.lang.Object lastinputobject The last input object.
 - 
preprocessorsprotected java.util.List<ITraverseProcessor> preprocessors The preprocessors.
 - 
classloaderprotected java.lang.ClassLoader classloader The classloader
 - 
rootobjectprotected java.lang.Object rootobject The root object.
 - 
usercontextprotected java.lang.Object usercontext A user context.
 - 
ignorewriteclassprotected boolean ignorewriteclass Flag indicating class names should not be written (can be temporarily disabled for one write).
 - 
nonanonclasscacheprotected java.util.Set<java.lang.Class<?>> nonanonclasscache The cache for non-inner classes.
 - 
stringpoolprotected java.util.Map<java.lang.String,java.lang.Integer> stringpool The string pool.
 - 
classidcacheprotected java.util.Map<java.lang.Class<?>,java.lang.Integer> classidcache Cache for class IDs.
 - 
classnamepoolprotected java.util.Map<java.lang.String,java.lang.Integer> classnamepool The class name pool.
 - 
writtenbytesprotected long writtenbytes The bytes written to the output.
 
- 
 - 
Constructor Detail- 
AbstractEncodingContextpublic AbstractEncodingContext(java.lang.Object rootobject, java.lang.Object usercontext, java.util.List<ITraverseProcessor> preprocessors, java.lang.ClassLoader classloader, SerializationConfig config)
 
- 
 - 
Method Detail- 
getPreprocessorspublic java.util.List<ITraverseProcessor> getPreprocessors() Returns the preprocessors.- Specified by:
- getPreprocessorsin interface- IEncodingContext
- Returns:
- The preprocessors
 
 - 
getClassLoaderpublic java.lang.ClassLoader getClassLoader() Gets the classloader.- Specified by:
- getClassLoaderin interface- IEncodingContext
- Returns:
- The classloader.
 
 - 
getRootObjectpublic java.lang.Object getRootObject() Get the rootobject.- Specified by:
- getRootObjectin interface- IRootObjectContext
- Returns:
- the rootobject.
 
 - 
getWrittenBytespublic long getWrittenBytes() Returns the number of bytes written.- Specified by:
- getWrittenBytesin interface- IEncodingContext
- Returns:
- The number of bytes written.
 
 - 
getUserContextpublic java.lang.Object getUserContext() Returns the user context.- Specified by:
- getUserContextin interface- IUserContextContainer
- Returns:
- The user context.
 
 - 
getNonInnerClassCachepublic java.util.Set<java.lang.Class<?>> getNonInnerClassCache() Returns the non-inner class cache.- Specified by:
- getNonInnerClassCachein interface- IEncodingContext
- Returns:
- The non-inner class cache.
 
 - 
createObjectIdpublic long createObjectId() Creates ID for an object.- Specified by:
- createObjectIdin interface- IEncodingContext
- Parameters:
- object- The object
- Returns:
- The ID.
 
 - 
setInputObjectpublic void setInputObject(java.lang.Object object) Sets the object for which the next createObjectId() call creates an ID.- Specified by:
- setInputObjectin interface- IEncodingContext
- Parameters:
- object- The object.
 
 - 
getObjectIdpublic java.lang.Long getObjectId(java.lang.Object object) Gets the ID of a known object.- Specified by:
- getObjectIdin interface- IEncodingContext
- Parameters:
- object- The object
- Returns:
- The ID.
 
 - 
setIgnoreNextClassWritepublic void setIgnoreNextClassWrite(boolean state) Puts the context in a state where the next call to writeClass is ignored.- Specified by:
- setIgnoreNextClassWritein interface- IEncodingContext
- Parameters:
- state- If true, the next class write will be ignored and the state reset.
 
 - 
isIgnoreNextClassWriteprotected boolean isIgnoreNextClassWrite() 
 - 
writeVarIntpublic void writeVarInt(long value) Writes a VarInt.- Specified by:
- writeVarIntin interface- IEncodingContext
- Parameters:
- value- Value being written.
 
 - 
writeSignedVarIntpublic void writeSignedVarInt(long value) Writes a signed VarInt.- Specified by:
- writeSignedVarIntin interface- IEncodingContext
- Parameters:
- value- Value being written.
 
 - 
writeStringpublic void writeString(java.lang.String string) Description copied from interface:IEncodingContextWrites a string to the context.- Specified by:
- writeStringin interface- IEncodingContext
- Parameters:
- string-
 
 - 
writeClasspublic void writeClass(java.lang.Class<?> clazz) Description copied from interface:IEncodingContextWrites a class to the context.- Specified by:
- writeClassin interface- IEncodingContext
- Parameters:
- clazz-
 
 - 
writeClassnamepublic int writeClassname(java.lang.String name) Description copied from interface:IEncodingContextWrites the name of a class.- Specified by:
- writeClassnamein interface- IEncodingContext
- Parameters:
- name- The name of the class.
 
 - 
writeBooleanpublic void writeBoolean(boolean bool) Writes a boolean.- Specified by:
- writeBooleanin interface- IEncodingContext
- Parameters:
- bool- The boolean.
 
 - 
startObjectFramepublic void startObjectFrame() Starts an object frame when using a context with framing support.- Specified by:
- startObjectFramein interface- IEncodingContext
 
 - 
startObjectFramepublic void startObjectFrame(boolean fixedsize) Starts an object frame when using a context with framing support.- Specified by:
- startObjectFramein interface- IEncodingContext
- 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).
 
 - 
stopObjectFramepublic void stopObjectFrame() Stops an object frame when using a context with framing support.- Specified by:
- stopObjectFramein interface- IEncodingContext
 
 - 
pooledWriteprotected void pooledWrite(java.util.Map<java.lang.String,java.lang.Integer> pool, java.lang.String string)Writes a string using a pool.- Parameters:
- string-
 
 
- 
 
-