Class ScriptingJsonObject
- java.lang.Object
-
- com.flowable.platform.engine.impl.scripting.ScriptingJsonObject
-
- All Implemented Interfaces:
ScriptingJsonNode
,Iterable<ScriptingJsonNode>
,Supplier<com.fasterxml.jackson.databind.JsonNode>
public class ScriptingJsonObject extends Object implements Supplier<com.fasterxml.jackson.databind.JsonNode>, ScriptingJsonNode
-
-
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)
- Specified by:
createChildObject
in interfaceScriptingJsonNode
-
createChildArray
public ScriptingJsonObject createChildArray(String fieldName)
- Specified by:
createChildArray
in interfaceScriptingJsonNode
-
putString
public ScriptingJsonObject putString(String fieldName, String value)
- Specified by:
putString
in interfaceScriptingJsonNode
-
putInteger
public ScriptingJsonObject putInteger(String fieldName, Number value)
- Specified by:
putInteger
in interfaceScriptingJsonNode
-
putInt
public ScriptingJsonObject putInt(String fieldName, int value)
- Specified by:
putInt
in interfaceScriptingJsonNode
-
putBoolean
public ScriptingJsonObject putBoolean(String fieldName, Boolean value)
- Specified by:
putBoolean
in interfaceScriptingJsonNode
-
putShort
public ScriptingJsonObject putShort(String fieldName, Number value)
- Specified by:
putShort
in interfaceScriptingJsonNode
-
putShort
public ScriptingJsonObject putShort(String fieldName, short value)
- Specified by:
putShort
in interfaceScriptingJsonNode
-
putLong
public ScriptingJsonObject putLong(String fieldName, Number value)
- Specified by:
putLong
in interfaceScriptingJsonNode
-
putLong
public ScriptingJsonObject putLong(String fieldName, long value)
- Specified by:
putLong
in interfaceScriptingJsonNode
-
putDouble
public ScriptingJsonObject putDouble(String fieldName, Number value)
- Specified by:
putDouble
in interfaceScriptingJsonNode
-
putDouble
public ScriptingJsonObject putDouble(String fieldName, double value)
- Specified by:
putDouble
in interfaceScriptingJsonNode
-
putFloat
public ScriptingJsonObject putFloat(String fieldName, Number value)
- Specified by:
putFloat
in interfaceScriptingJsonNode
-
putFloat
public ScriptingJsonObject putFloat(String fieldName, float value)
- Specified by:
putFloat
in interfaceScriptingJsonNode
-
putObject
public ScriptingJsonObject putObject(String fieldName, Object value)
- Specified by:
putObject
in interfaceScriptingJsonNode
-
putNull
public ScriptingJsonObject putNull(String fieldName)
- Specified by:
putNull
in interfaceScriptingJsonNode
-
addString
public ScriptingJsonObject addString(String value)
- Specified by:
addString
in interfaceScriptingJsonNode
-
addInteger
public ScriptingJsonObject addInteger(Number value)
- Specified by:
addInteger
in interfaceScriptingJsonNode
-
addInt
public ScriptingJsonObject addInt(int value)
- Specified by:
addInt
in interfaceScriptingJsonNode
-
addBoolean
public ScriptingJsonObject addBoolean(Boolean value)
- Specified by:
addBoolean
in interfaceScriptingJsonNode
-
addShort
public ScriptingJsonObject addShort(Number value)
- Specified by:
addShort
in interfaceScriptingJsonNode
-
addShort
public ScriptingJsonObject addShort(short value)
- Specified by:
addShort
in interfaceScriptingJsonNode
-
addLong
public ScriptingJsonObject addLong(Number value)
- Specified by:
addLong
in interfaceScriptingJsonNode
-
addLong
public ScriptingJsonObject addLong(long value)
- Specified by:
addLong
in interfaceScriptingJsonNode
-
addDouble
public ScriptingJsonObject addDouble(Number value)
- Specified by:
addDouble
in interfaceScriptingJsonNode
-
addDouble
public ScriptingJsonObject addDouble(double value)
- Specified by:
addDouble
in interfaceScriptingJsonNode
-
addFloat
public ScriptingJsonObject addFloat(Number value)
- Specified by:
addFloat
in interfaceScriptingJsonNode
-
addFloat
public ScriptingJsonObject addFloat(float value)
- Specified by:
addFloat
in interfaceScriptingJsonNode
-
addObject
public ScriptingJsonObject addObject(Object value)
- Specified by:
addObject
in interfaceScriptingJsonNode
-
addNull
public ScriptingJsonObject addNull()
- Specified by:
addNull
in interfaceScriptingJsonNode
-
path
public ScriptingJsonObject path(String path)
- Specified by:
path
in interfaceScriptingJsonNode
-
path
public ScriptingJsonObject path(int index)
- Specified by:
path
in interfaceScriptingJsonNode
-
size
public int size()
- Specified by:
size
in interfaceScriptingJsonNode
- 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()
- Specified by:
asInteger
in interfaceScriptingJsonNode
- 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()
- Specified by:
asLong
in interfaceScriptingJsonNode
- Returns:
- this number value as long.
- Throws:
FlowableException
- when this node is empty or null or not a number.
-
asBoolean
public Boolean asBoolean()
- Specified by:
asBoolean
in interfaceScriptingJsonNode
- Returns:
- this value as boolean.
- Throws:
FlowableException
- when this node is empty or null or not a boolean.
-
asDouble
public Double asDouble()
- Specified by:
asDouble
in interfaceScriptingJsonNode
- Returns:
- this number value as double.
- Throws:
FlowableException
- when this node is empty or null or not a number.
-
asString
public String asString()
- Specified by:
asString
in interfaceScriptingJsonNode
- 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<ScriptingJsonNode> iterator()
- Specified by:
iterator
in interfaceIterable<ScriptingJsonNode>
- 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.
-
fieldNames
public Collection<String> fieldNames()
- Specified by:
fieldNames
in interfaceScriptingJsonNode
- Returns:
- collection of field names for object nodes. Empty collection for non-object nodes.
-
isValue
public boolean isValue()
- Specified by:
isValue
in interfaceScriptingJsonNode
- Returns:
- true if this json node is a value node.
-
isArray
public boolean isArray()
- Specified by:
isArray
in interfaceScriptingJsonNode
- Returns:
- true if this json node is an array node.
-
isObject
public boolean isObject()
- Specified by:
isObject
in interfaceScriptingJsonNode
- Returns:
- true if this json node is an object node.
-
isString
public boolean isString()
- Specified by:
isString
in interfaceScriptingJsonNode
- Returns:
- true if this json node is a string
-
isNumber
public boolean isNumber()
- Specified by:
isNumber
in interfaceScriptingJsonNode
- Returns:
- true if this json node is a number
-
isBoolean
public boolean isBoolean()
- Specified by:
isBoolean
in interfaceScriptingJsonNode
- Returns:
- true if this json node is a boolean
-
isNonNull
public boolean isNonNull()
- Specified by:
isNonNull
in interfaceScriptingJsonNode
-
isPresent
public boolean isPresent()
- Specified by:
isPresent
in interfaceScriptingJsonNode
-
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(ScriptingJsonNode)
-
-