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 Summary
Nested Classes Modifier and Type Class Description static classJsonWriteContext.TryWriteTry.style monad for stateful write to the write context, handling first writes specially.
-
Field Summary
Fields 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 Summary
Constructors 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 Summary
All 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
-
buffer
protected java.lang.StringBuffer buffer
-
writeclass
protected boolean writeclass
-
writeid
protected boolean writeid
-
excludes
protected java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes
-
objectcnt
protected int objectcnt
-
knownobjects
protected java.util.Map<java.lang.Object,java.lang.Integer> knownobjects
-
rootobject
protected java.lang.Object rootobject
-
currentinputobject
protected java.lang.Object currentinputobject
-
usercontext
protected java.lang.Object usercontext
-
-
Constructor Detail
-
JsonWriteContext
public JsonWriteContext(boolean writeclass)
Create a new write context.
-
JsonWriteContext
public JsonWriteContext(boolean writeclass, java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.String>> excludes)Create a new write context.
-
JsonWriteContext
public 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
-
getRootObject
public java.lang.Object getRootObject()
Get the rootobject.- Specified by:
getRootObjectin interfaceIRootObjectContext- Returns:
- the rootobject.
-
write
public JsonWriteContext write(java.lang.String str)
Write a string to the buffer.
-
writeString
public JsonWriteContext writeString(java.lang.String str)
Write a string to the buffer.
-
writeNameString
public JsonWriteContext writeNameString(java.lang.String name, java.lang.String str)
Write a string to the buffer.
-
writeNameValue
public JsonWriteContext writeNameValue(java.lang.String name, java.lang.Object val)
Write a string to the buffer.
-
writeNameValue
public JsonWriteContext writeNameValue(java.lang.String name, int val)
Write a string to the buffer.
-
writeNameValue
public JsonWriteContext writeNameValue(java.lang.String name, long val)
Write a string to the buffer.
-
writeNameValue
public JsonWriteContext writeNameValue(java.lang.String name, boolean val)
Write a string to the buffer.
-
writeNameValue
public JsonWriteContext writeNameValue(java.lang.String name, java.lang.Class<?> val)
Write a string to the buffer.
-
writeClass
public void writeClass(java.lang.Class<?> clazz)
Write the classname.- Parameters:
object-
-
writeId
public void writeId()
Write the classname.- Parameters:
object-
-
getString
public java.lang.String getString()
-
isWriteClass
public boolean isWriteClass()
Get the writeclass.- Returns:
- The writeclass
-
isWriteId
public boolean isWriteId()
Get the writeid.- Returns:
- The writeid
-
getUserContext
public java.lang.Object getUserContext()
Returns the user context.- Specified by:
getUserContextin interfaceIUserContextContainer- Returns:
- The user context.
-
setUserContext
public void setUserContext(java.lang.Object usercontext)
Sets the user context.- Parameters:
usercontext- The user context.
-
addObject
public void addObject(java.lang.Object obj)
-
getObjectId
public java.lang.Integer getObjectId(java.lang.Object object)
-
incObjectCount
public void incObjectCount()
-
isPropertyExcluded
public boolean isPropertyExcluded(java.lang.Class<?> clazz, java.lang.String name)Test if a property should be excluded from serialization.
-
getCurrentInputObject
public java.lang.Object getCurrentInputObject()
- Returns:
- the currentinputobject
-
setCurrentInputObject
public void setCurrentInputObject(java.lang.Object currentinputobject)
Sets the currentinputobject.- Parameters:
currentinputobject- The currentinputobject to set
-
encodeJsonString
public static java.lang.String encodeJsonString(java.lang.String string)
-
-