Class JsonWriteContext
- java.lang.Object
- 
- jadex.transformation.jsonserializer.processors.JsonWriteContext
 
- 
- All Implemented Interfaces:
- IRootObjectContext,- IUserContextContainer
 
 public class JsonWriteContext extends java.lang.Object implements IRootObjectContext 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classJsonWriteContext.TryWriteTry.style monad for stateful write to the write context, handling first writes specially.
 - 
Field SummaryFields Modifier and Type Field Description protected java.lang.StringBufferbufferprotected java.lang.Objectcurrentinputobjectprotected java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>>excludesprotected java.util.Map<java.lang.Object,java.lang.Integer>knownobjectsprotected intobjectcntprotected java.lang.Objectrootobjectprotected java.lang.Objectusercontextprotected booleanwriteclassprotected booleanwriteid
 - 
Constructor SummaryConstructors Constructor Description JsonWriteContext(boolean writeclass)Create a new write context.JsonWriteContext(boolean writeclass, boolean writeid, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes)Create a new write context.JsonWriteContext(boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes)Create a new write context.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObject(java.lang.Object obj)static java.lang.StringencodeJsonString(java.lang.String string)java.lang.ObjectgetCurrentInputObject()java.lang.IntegergetObjectId(java.lang.Object object)java.lang.ObjectgetRootObject()Get the rootobject.java.lang.StringgetString()java.lang.ObjectgetUserContext()Returns the user context.voidincObjectCount()booleanisPropertyExcluded(java.lang.Class<?> clazz, java.lang.String name)Test if a property should be excluded from serialization.booleanisWriteClass()Get the writeclass.booleanisWriteId()Get the writeid.voidsetCurrentInputObject(java.lang.Object currentinputobject)Sets the currentinputobject.voidsetUserContext(java.lang.Object usercontext)Sets the user context.JsonWriteContextwrite(java.lang.String str)Write a string to the buffer.voidwriteClass(java.lang.Class<?> clazz)Write the classname.voidwriteId()Write the classname.JsonWriteContextwriteNameString(java.lang.String name, java.lang.String str)Write a string to the buffer.JsonWriteContextwriteNameValue(java.lang.String name, boolean val)Write a string to the buffer.JsonWriteContextwriteNameValue(java.lang.String name, int val)Write a string to the buffer.JsonWriteContextwriteNameValue(java.lang.String name, long val)Write a string to the buffer.JsonWriteContextwriteNameValue(java.lang.String name, java.lang.Class<?> val)Write a string to the buffer.JsonWriteContextwriteNameValue(java.lang.String name, java.lang.Object val)Write a string to the buffer.JsonWriteContextwriteString(java.lang.String str)Write a string to the buffer.
 
- 
- 
- 
Field Detail- 
bufferprotected java.lang.StringBuffer buffer 
 - 
writeclassprotected boolean writeclass 
 - 
writeidprotected boolean writeid 
 - 
excludesprotected java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes 
 - 
objectcntprotected int objectcnt 
 - 
knownobjectsprotected java.util.Map<java.lang.Object,java.lang.Integer> knownobjects 
 - 
rootobjectprotected java.lang.Object rootobject 
 - 
currentinputobjectprotected java.lang.Object currentinputobject 
 - 
usercontextprotected java.lang.Object usercontext 
 
- 
 - 
Constructor Detail- 
JsonWriteContextpublic JsonWriteContext(boolean writeclass) Create a new write context.
 - 
JsonWriteContextpublic JsonWriteContext(boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes)Create a new write context.
 - 
JsonWriteContextpublic JsonWriteContext(boolean writeclass, boolean writeid, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes)Create a new write context.
 
- 
 - 
Method Detail- 
getRootObjectpublic java.lang.Object getRootObject() Get the rootobject.- Specified by:
- getRootObjectin interface- IRootObjectContext
- Returns:
- the rootobject.
 
 - 
writepublic JsonWriteContext write(java.lang.String str) Write a string to the buffer.
 - 
writeStringpublic JsonWriteContext writeString(java.lang.String str) Write a string to the buffer.
 - 
writeNameStringpublic JsonWriteContext writeNameString(java.lang.String name, java.lang.String str) Write a string to the buffer.
 - 
writeNameValuepublic JsonWriteContext writeNameValue(java.lang.String name, java.lang.Object val) Write a string to the buffer.
 - 
writeNameValuepublic JsonWriteContext writeNameValue(java.lang.String name, int val) Write a string to the buffer.
 - 
writeNameValuepublic JsonWriteContext writeNameValue(java.lang.String name, long val) Write a string to the buffer.
 - 
writeNameValuepublic JsonWriteContext writeNameValue(java.lang.String name, boolean val) Write a string to the buffer.
 - 
writeNameValuepublic JsonWriteContext writeNameValue(java.lang.String name, java.lang.Class<?> val) Write a string to the buffer.
 - 
writeClasspublic void writeClass(java.lang.Class<?> clazz) Write the classname.- Parameters:
- object-
 
 - 
writeIdpublic void writeId() Write the classname.- Parameters:
- object-
 
 - 
getStringpublic java.lang.String getString() 
 - 
isWriteClasspublic boolean isWriteClass() Get the writeclass.- Returns:
- The writeclass
 
 - 
isWriteIdpublic boolean isWriteId() Get the writeid.- Returns:
- The writeid
 
 - 
getUserContextpublic java.lang.Object getUserContext() Returns the user context.- Specified by:
- getUserContextin interface- IUserContextContainer
- Returns:
- The user context.
 
 - 
setUserContextpublic void setUserContext(java.lang.Object usercontext) Sets the user context.- Parameters:
- usercontext- The user context.
 
 - 
addObjectpublic void addObject(java.lang.Object obj) 
 - 
getObjectIdpublic java.lang.Integer getObjectId(java.lang.Object object) 
 - 
incObjectCountpublic void incObjectCount() 
 - 
isPropertyExcludedpublic boolean isPropertyExcluded(java.lang.Class<?> clazz, java.lang.String name)Test if a property should be excluded from serialization.
 - 
getCurrentInputObjectpublic java.lang.Object getCurrentInputObject() - Returns:
- the currentinputobject
 
 - 
setCurrentInputObjectpublic void setCurrentInputObject(java.lang.Object currentinputobject) Sets the currentinputobject.- Parameters:
- currentinputobject- The currentinputobject to set
 
 - 
encodeJsonStringpublic static java.lang.String encodeJsonString(java.lang.String string) 
 
- 
 
-