Class JacksonJsonNode
java.lang.Object
org.camunda.spin.Spin<SpinJsonNode>
org.camunda.spin.json.SpinJsonNode
org.camunda.spin.impl.json.jackson.JacksonJsonNode
Wrapper for a Jackson Json Tree Node.
- Author:
- Thorben Lindhauer, Stefan Hentschel
-
Field Summary
Modifier and TypeFieldDescriptionprotected final JacksonJsonDataFormat
protected final com.fasterxml.jackson.databind.JsonNode
-
Constructor Summary
ConstructorDescriptionJacksonJsonNode
(com.fasterxml.jackson.databind.JsonNode jsonNode, JacksonJsonDataFormat dataFormat) -
Method Summary
Modifier and TypeMethodDescriptionAppends a object to the end of the current array nodeGet this node as a boolean value.boolean
Returnstrue
if the array contains the specified object.deleteProp
(String name) Remove a property of the given node by name.deleteProp
(List<String> names) Removes a number of properties by a given list of names.elements()
Get this node as list.Get the field names of this node (i.e.protected Integer
getCorrectIndex
(Integer index) fetch correct array index if index is less than 0 ArrayNode will convert all negative integers into 0...Provides the name of the dataformat used by this spin.com.fasterxml.jackson.databind.node.JsonNodeType
boolean
Check if this node has a property with the given name.Fetches the first index of the searched object in an array.insertAfter
(Object searchObject, Object insertObject) Inserts an object AFTER an specific object in an arrayAppends an object at a specific point in an arrayinsertBefore
(Object searchObject, Object insertObject) Inserts an object BEFORE an specific object in an arrayisArray()
Check if this node is a array value.Check if this node is a boolean value.isNull()
Check if this node represents a null value.isNumber()
Check if this node is a number value.boolean
isObject()
Check if this node is an object node.isString()
Check if this node is a string value.isValue()
Check if this node is a value.Creates a JsonPath query on this element.lastIndexOf
(Object searchObject) Fetches the last index of the searched object in an array.protected int
lookupArray
(com.fasterxml.jackson.databind.JsonNode searchNode, int direction) <C> C
mapTo
(com.fasterxml.jackson.databind.JavaType type) Maps the json represented by this object to a java object of the given type.
Note: the desired target type is not validated and needs to be trusted.<C> C
Maps the json represented by this object to a java object of the given type.
Note: the desired target type is not validated and needs to be trusted.<C> C
Maps the json represented by this object to a java object of the given type.Get this node as a number value.Get the property of this node with the given name.Set a new boolean property in this node.Set a new float property in this node.Set a new int property in this node.Set a new long property in this node.Set a new Boolean property in this node.Set a new Number property in this node.Set a new String property in this node.Set a new List property in this node.Set a new Map property in this node.prop
(String name, SpinJsonNode newProperty) Set a new SpinJsonNode Object property in this node.Removes the first appearance of an object from the current arrayremoveAt
(int index) removes an object at the specific index of the current arrayremoveLast
(Object property) Removes the last appearance of an object from the current arrayGet this node as a string value.toString()
Returns the wrapped object as string representation.com.fasterxml.jackson.databind.JsonNode
unwrap()
Return the wrapped object.value()
Gets the actual value of the node, in case it is a Boolean/String/Number/Null node.void
writeToWriter
(Writer writer) Writes the wrapped object to a existing writer.
-
Field Details
-
jsonNode
protected final com.fasterxml.jackson.databind.JsonNode jsonNode -
dataFormat
-
-
Constructor Details
-
JacksonJsonNode
public JacksonJsonNode(com.fasterxml.jackson.databind.JsonNode jsonNode, JacksonJsonDataFormat dataFormat)
-
-
Method Details
-
getDataFormatName
Description copied from class:Spin
Provides the name of the dataformat used by this spin.- Specified by:
getDataFormatName
in classSpin<SpinJsonNode>
- Returns:
- the name of the dataformat used by this Spin.
-
unwrap
public com.fasterxml.jackson.databind.JsonNode unwrap()Description copied from class:Spin
Return the wrapped object. The return type of this method depends on the concrete data format.- Specified by:
unwrap
in classSpin<SpinJsonNode>
- Returns:
- the object wrapped by this wrapper.
-
toString
Description copied from class:Spin
Returns the wrapped object as string representation.- Specified by:
toString
in classSpin<SpinJsonNode>
- Returns:
- the string representation
-
writeToWriter
Description copied from class:Spin
Writes the wrapped object to a existing writer.- Specified by:
writeToWriter
in classSpin<SpinJsonNode>
- Parameters:
writer
- the writer to write to
-
getCorrectIndex
fetch correct array index if index is less than 0 ArrayNode will convert all negative integers into 0...- Parameters:
index
- wanted index- Returns:
Integer
new index
-
lookupArray
protected int lookupArray(com.fasterxml.jackson.databind.JsonNode searchNode, int direction) -
indexOf
Description copied from class:SpinJsonNode
Fetches the first index of the searched object in an array.- Specified by:
indexOf
in classSpinJsonNode
- Parameters:
searchObject
- Object for which the index should be searched.- Returns:
Integer
index of searchObject.
-
lastIndexOf
Description copied from class:SpinJsonNode
Fetches the last index of the searched object in an array.- Specified by:
lastIndexOf
in classSpinJsonNode
- Parameters:
searchObject
- Object for which the index should be searched.- Returns:
Integer
index of searchObject.
-
contains
Description copied from class:SpinJsonNode
Returnstrue
if the array contains the specified object.- Specified by:
contains
in classSpinJsonNode
- Parameters:
searchObject
- Object for which the array should be searched.- Returns:
true
if the array contains the object.
-
isObject
public boolean isObject()Description copied from class:SpinJsonNode
Check if this node is an object node.- Specified by:
isObject
in classSpinJsonNode
- Returns:
- true if the node is an object, false otherwise
-
hasProp
Description copied from class:SpinJsonNode
Check if this node has a property with the given name.- Specified by:
hasProp
in classSpinJsonNode
- Parameters:
name
- the name of the property- Returns:
- true if this node has a property with this name, false otherwise
-
prop
Description copied from class:SpinJsonNode
Get the property of this node with the given name.- Specified by:
prop
in classSpinJsonNode
- Parameters:
name
- the name of the property- Returns:
SpinJsonNode
representation of the property
-
prop
Description copied from class:SpinJsonNode
Set a new String property in this node.- Specified by:
prop
in classSpinJsonNode
- Parameters:
name
- the name of the new propertynewProperty
- the new String property- Returns:
SpinJsonNode
representation of the current node
-
prop
Description copied from class:SpinJsonNode
Set a new Number property in this node.- Specified by:
prop
in classSpinJsonNode
- Parameters:
name
- the name of the new propertynewProperty
- the new Number property- Returns:
SpinJsonNode
representation of the current node
-
prop
Description copied from class:SpinJsonNode
Set a new int property in this node.- Specified by:
prop
in classSpinJsonNode
- Parameters:
name
- the name of the new propertynewProperty
- the new int property- Returns:
SpinJsonNode
representation of the current node
-
prop
Description copied from class:SpinJsonNode
Set a new float property in this node.- Specified by:
prop
in classSpinJsonNode
- Parameters:
name
- the name of the new propertynewProperty
- the new float property- Returns:
SpinJsonNode
representation of the current node
-
prop
Description copied from class:SpinJsonNode
Set a new long property in this node.- Specified by:
prop
in classSpinJsonNode
- Parameters:
name
- the name of the new propertynewProperty
- the new long property- Returns:
SpinJsonNode
representation of the current node
-
prop
Description copied from class:SpinJsonNode
Set a new boolean property in this node.- Specified by:
prop
in classSpinJsonNode
- Parameters:
name
- the name of the new propertynewProperty
- the new boolean property- Returns:
SpinJsonNode
representation of the current node
-
prop
Description copied from class:SpinJsonNode
Set a new Boolean property in this node.- Specified by:
prop
in classSpinJsonNode
- Parameters:
name
- the name of the new propertynewProperty
- the new Boolean property- Returns:
SpinJsonNode
representation of the current node
-
prop
Description copied from class:SpinJsonNode
Set a new List property in this node.- Specified by:
prop
in classSpinJsonNode
- Parameters:
name
- the name of the new propertynewProperty
- the new List property- Returns:
SpinJsonNode
representation of the current node
-
propList
-
prop
Description copied from class:SpinJsonNode
Set a new Map property in this node.- Specified by:
prop
in classSpinJsonNode
- Parameters:
name
- the name of the new propertynewProperty
- the new Map property- Returns:
SpinJsonNode
representation of the current node
-
prop
Description copied from class:SpinJsonNode
Set a new SpinJsonNode Object property in this node.- Specified by:
prop
in classSpinJsonNode
- Parameters:
name
- the name of the new propertynewProperty
- the new SpinJsonNode Object property- Returns:
SpinJsonNode
representation of the current node
-
deleteProp
Description copied from class:SpinJsonNode
Remove a property of the given node by name.- Specified by:
deleteProp
in classSpinJsonNode
- Parameters:
name
- name of the property- Returns:
SpinJsonNode
representation of the current node
-
deleteProp
Description copied from class:SpinJsonNode
Removes a number of properties by a given list of names.- Specified by:
deleteProp
in classSpinJsonNode
- Parameters:
names
- list of names- Returns:
SpinJsonNode
representation of the current node
-
append
Description copied from class:SpinJsonNode
Appends a object to the end of the current array node- Specified by:
append
in classSpinJsonNode
- Parameters:
property
- property which should be append- Returns:
SpinJsonNode
representation of the current node
-
insertAt
Description copied from class:SpinJsonNode
Appends an object at a specific point in an array- Specified by:
insertAt
in classSpinJsonNode
- Parameters:
index
- Index in current node where the new property should be appended.property
- Object which should be appended.- Returns:
SpinJsonNode
representation of the current node.
-
insertBefore
Description copied from class:SpinJsonNode
Inserts an object BEFORE an specific object in an array- Specified by:
insertBefore
in classSpinJsonNode
- Parameters:
searchObject
- Object which is searchedinsertObject
- Object which will be inserted- Returns:
SpinJsonNode
representation of the current node
-
insertAfter
Description copied from class:SpinJsonNode
Inserts an object AFTER an specific object in an array- Specified by:
insertAfter
in classSpinJsonNode
- Parameters:
searchObject
- Object which is searchedinsertObject
- Object which will be inserted- Returns:
SpinJsonNode
representation of the current node
-
remove
Description copied from class:SpinJsonNode
Removes the first appearance of an object from the current array- Specified by:
remove
in classSpinJsonNode
- Parameters:
property
- object which should be deleted- Returns:
SpinJsonNode
representation of the current node
-
removeLast
Description copied from class:SpinJsonNode
Removes the last appearance of an object from the current array- Specified by:
removeLast
in classSpinJsonNode
- Parameters:
property
- object which should be deleted- Returns:
SpinJsonNode
representation of the current node
-
removeAt
Description copied from class:SpinJsonNode
removes an object at the specific index of the current array- Specified by:
removeAt
in classSpinJsonNode
- Parameters:
index
- Index of the array- Returns:
SpinJsonNode
representation of the current node
-
isBoolean
Description copied from class:SpinJsonNode
Check if this node is a boolean value.- Specified by:
isBoolean
in classSpinJsonNode
- Returns:
- true if this node is a boolean value, false otherwise
-
boolValue
Description copied from class:SpinJsonNode
Get this node as a boolean value.- Specified by:
boolValue
in classSpinJsonNode
- Returns:
- the boolean value of this node
-
isNumber
Description copied from class:SpinJsonNode
Check if this node is a number value.- Specified by:
isNumber
in classSpinJsonNode
- Returns:
- true if this node is a number value, false otherwise
-
numberValue
Description copied from class:SpinJsonNode
Get this node as a number value.- Specified by:
numberValue
in classSpinJsonNode
- Returns:
- the number value of this node
-
isString
Description copied from class:SpinJsonNode
Check if this node is a string value.- Specified by:
isString
in classSpinJsonNode
- Returns:
- true if this node is a string value, false otherwise
-
stringValue
Description copied from class:SpinJsonNode
Get this node as a string value.- Specified by:
stringValue
in classSpinJsonNode
- Returns:
- the string value of this node
-
isNull
Description copied from class:SpinJsonNode
Check if this node represents a null value.- Specified by:
isNull
in classSpinJsonNode
- Returns:
- true if this node is a null value, false otherwise
-
isValue
Description copied from class:SpinJsonNode
Check if this node is a value.- Specified by:
isValue
in classSpinJsonNode
- Returns:
- true if this node is a value, false otherwise
-
value
Description copied from class:SpinJsonNode
Gets the actual value of the node, in case it is a Boolean/String/Number/Null node. In that case a Java Boolean/String/Number or null is returned.- Specified by:
value
in classSpinJsonNode
- Returns:
- the value of this node
-
isArray
Description copied from class:SpinJsonNode
Check if this node is a array value.- Specified by:
isArray
in classSpinJsonNode
- Returns:
- true if this node is a array value, false otherwise
-
elements
Description copied from class:SpinJsonNode
Get this node as list. If the current node is an array, this method returns aSpinList
which contains copies of all JSON nodes contained in the current node. Changes to the the elements in the list will not propagate to the original nodes.- Specified by:
elements
in classSpinJsonNode
- Returns:
- the list value of this node
-
fieldNames
Description copied from class:SpinJsonNode
Get the field names of this node (i.e. the property names).- Specified by:
fieldNames
in classSpinJsonNode
- Returns:
- the list of field names
-
getNodeType
public com.fasterxml.jackson.databind.node.JsonNodeType getNodeType() -
jsonPath
Description copied from class:SpinJsonNode
Creates a JsonPath query on this element.- Specified by:
jsonPath
in classSpinJsonNode
- Parameters:
expression
- the JsonPath expression- Returns:
- the JsonPath query
-
mapTo
Maps the json represented by this object to a java object of the given type.
Note: the desired target type is not validated and needs to be trusted.- Specified by:
mapTo
in classSpin<SpinJsonNode>
- Parameters:
type
- the java class to map to- Returns:
- the mapped object
- Throws:
SpinJsonException
- if the json representation cannot be mapped to the specified type
-
mapTo
Maps the json represented by this object to a java object of the given type. Argument is to be supplied in Jackson's canonical type string format (seeResolvedType.toCanonical()
).
Note: the desired target type is not validated and needs to be trusted.- Specified by:
mapTo
in classSpin<SpinJsonNode>
- Parameters:
type
- the class name to map to- Returns:
- the mapped object
- Throws:
SpinJsonException
- if the json representation cannot be mapped to the specified typeSpinJsonDataFormatException
- if the parameter does not match a valid type
-
mapTo
public <C> C mapTo(com.fasterxml.jackson.databind.JavaType type) Maps the json represented by this object to a java object of the given type.
Note: the desired target type is not validated and needs to be trusted.- Throws:
SpinJsonException
- if the json representation cannot be mapped to the specified type
-