Class ScriptingJsonObject
- java.lang.Object
-
- com.flowable.platform.engine.impl.scripting.ScriptingJsonObject
-
- All Implemented Interfaces:
Iterable<ScriptingJsonObject>
,Supplier<com.fasterxml.jackson.databind.JsonNode>
public class ScriptingJsonObject extends Object implements Supplier<com.fasterxml.jackson.databind.JsonNode>, Iterable<ScriptingJsonObject>
-
-
Field Summary
Fields Modifier and Type Field Description protected com.fasterxml.jackson.databind.JsonNode
jsonNode
-
Constructor Summary
Constructors Constructor Description ScriptingJsonObject(com.fasterxml.jackson.databind.JsonNode jsonNode)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
createChildObject
public ScriptingJsonObject createChildObject(String fieldName)
-
createChildArray
public ScriptingJsonObject createChildArray(String fieldName)
-
putString
public ScriptingJsonObject putString(String fieldName, String value)
-
putInteger
public ScriptingJsonObject putInteger(String fieldName, Number value)
-
putInt
public ScriptingJsonObject putInt(String fieldName, int value)
-
putBoolean
public ScriptingJsonObject putBoolean(String fieldName, Boolean value)
-
putShort
public ScriptingJsonObject putShort(String fieldName, Number value)
-
putShort
public ScriptingJsonObject putShort(String fieldName, short value)
-
putLong
public ScriptingJsonObject putLong(String fieldName, Number value)
-
putLong
public ScriptingJsonObject putLong(String fieldName, long value)
-
putDouble
public ScriptingJsonObject putDouble(String fieldName, Number value)
-
putDouble
public ScriptingJsonObject putDouble(String fieldName, double value)
-
putFloat
public ScriptingJsonObject putFloat(String fieldName, Number value)
-
putFloat
public ScriptingJsonObject putFloat(String fieldName, float value)
-
putObject
public ScriptingJsonObject putObject(String fieldName, Object value)
-
putNull
public ScriptingJsonObject putNull(String fieldName)
-
addString
public ScriptingJsonObject addString(String value)
-
addInteger
public ScriptingJsonObject addInteger(Number value)
-
addInt
public ScriptingJsonObject addInt(int value)
-
addBoolean
public ScriptingJsonObject addBoolean(Boolean value)
-
addShort
public ScriptingJsonObject addShort(Number value)
-
addShort
public ScriptingJsonObject addShort(short value)
-
addLong
public ScriptingJsonObject addLong(Number value)
-
addLong
public ScriptingJsonObject addLong(long value)
-
addDouble
public ScriptingJsonObject addDouble(Number value)
-
addDouble
public ScriptingJsonObject addDouble(double value)
-
addFloat
public ScriptingJsonObject addFloat(Number value)
-
addFloat
public ScriptingJsonObject addFloat(float value)
-
addObject
public ScriptingJsonObject addObject(Object value)
-
addNull
public ScriptingJsonObject addNull()
-
path
public ScriptingJsonObject path(String path)
-
path
public ScriptingJsonObject path(int index)
-
size
public int size()
- Returns:
- the number of elements for this json node (array length for array nodes or number of attributes for object nodes).
-
asInteger
public Integer asInteger()
- Returns:
- this value as integer in case it is a numeric value.
- Throws:
FlowableException
- when this node is empty or null, not a number or exceeds integer range.
-
asLong
public Long asLong()
- Returns:
- this number value as long.
- Throws:
FlowableException
- when this node is empty or null or not a number.
-
asBoolean
public Boolean asBoolean()
- Returns:
- this value as boolean.
- Throws:
FlowableException
- when this node is empty or null or not a boolean.
-
asDouble
public Double asDouble()
- Returns:
- this number value as double.
- Throws:
FlowableException
- when this node is empty or null or not a number.
-
asString
public String asString()
- Returns:
- a string representation of this node, if this node is a value node (
isValue()
returns true). - Throws:
FlowableException
- when this node is not a value node.
-
iterator
public Iterator<ScriptingJsonObject> iterator()
- Specified by:
iterator
in interfaceIterable<ScriptingJsonObject>
- Returns:
- an iterator of this node. Wraps each object into a ScriptingJsonObject when this node is an array node. Otherwise, a single item iterator is returned.
-
isValue
public boolean isValue()
- Returns:
- true if this json node is a value node.
-
isArray
public boolean isArray()
- Returns:
- true if this json node is an array node.
-
isObject
public boolean isObject()
- Returns:
- true if this json node is an object node.
-
isString
public boolean isString()
- Returns:
- true if this json node is a string
-
isNumber
public boolean isNumber()
- Returns:
- true if this json node is a number
-
isBoolean
public boolean isBoolean()
- Returns:
- true if this json node is a boolean
-
isNonNull
public boolean isNonNull()
-
isPresent
public boolean isPresent()
-
checkForNull
protected void checkForNull(String action)
-
checkIsObjectNode
protected com.fasterxml.jackson.databind.node.ObjectNode checkIsObjectNode(String action)
-
checkIsArrayNode
protected com.fasterxml.jackson.databind.node.ArrayNode checkIsArrayNode(String action)
-
get
public com.fasterxml.jackson.databind.JsonNode get()
-
getJsonNode
public com.fasterxml.jackson.databind.JsonNode getJsonNode()
-
toString
public String toString()
Returns a toString representation of this ScriptingJsonObject.NOTE: Even though this method returns some json content, do not rely on it for parsing the content. Use a proper json generator to create a json string instead e.g.
ScriptingJsonUtils.jsonToString(ScriptingJsonObject)
-
-