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