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
FieldsModifier and TypeFieldDescriptionprotected final JacksonJsonDataFormatprotected final com.fasterxml.jackson.databind.JsonNode -
Constructor Summary
ConstructorsConstructorDescriptionJacksonJsonNode(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.booleanReturnstrueif 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 IntegergetCorrectIndex(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.JsonNodeTypebooleanCheck 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.booleanisObject()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 intlookupArray(com.fasterxml.jackson.databind.JsonNode searchNode, int direction) <C> CmapTo(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> CMaps 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> CMaps 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.JsonNodeunwrap()Return the wrapped object.value()Gets the actual value of the node, in case it is a Boolean/String/Number/Null node.voidwriteToWriter(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:SpinProvides the name of the dataformat used by this spin.- Specified by:
getDataFormatNamein classSpin<SpinJsonNode>- Returns:
- the name of the dataformat used by this Spin.
-
unwrap
public com.fasterxml.jackson.databind.JsonNode unwrap()Description copied from class:SpinReturn the wrapped object. The return type of this method depends on the concrete data format.- Specified by:
unwrapin classSpin<SpinJsonNode>- Returns:
- the object wrapped by this wrapper.
-
toString
Description copied from class:SpinReturns the wrapped object as string representation.- Specified by:
toStringin classSpin<SpinJsonNode>- Returns:
- the string representation
-
writeToWriter
Description copied from class:SpinWrites the wrapped object to a existing writer.- Specified by:
writeToWriterin 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:
Integernew index
-
lookupArray
protected int lookupArray(com.fasterxml.jackson.databind.JsonNode searchNode, int direction) -
indexOf
Description copied from class:SpinJsonNodeFetches the first index of the searched object in an array.- Specified by:
indexOfin classSpinJsonNode- Parameters:
searchObject- Object for which the index should be searched.- Returns:
Integerindex of searchObject.
-
lastIndexOf
Description copied from class:SpinJsonNodeFetches the last index of the searched object in an array.- Specified by:
lastIndexOfin classSpinJsonNode- Parameters:
searchObject- Object for which the index should be searched.- Returns:
Integerindex of searchObject.
-
contains
Description copied from class:SpinJsonNodeReturnstrueif the array contains the specified object.- Specified by:
containsin classSpinJsonNode- Parameters:
searchObject- Object for which the array should be searched.- Returns:
trueif the array contains the object.
-
isObject
public boolean isObject()Description copied from class:SpinJsonNodeCheck if this node is an object node.- Specified by:
isObjectin classSpinJsonNode- Returns:
- true if the node is an object, false otherwise
-
hasProp
Description copied from class:SpinJsonNodeCheck if this node has a property with the given name.- Specified by:
hasPropin 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:SpinJsonNodeGet the property of this node with the given name.- Specified by:
propin classSpinJsonNode- Parameters:
name- the name of the property- Returns:
SpinJsonNoderepresentation of the property
-
prop
Description copied from class:SpinJsonNodeSet a new String property in this node.- Specified by:
propin classSpinJsonNode- Parameters:
name- the name of the new propertynewProperty- the new String property- Returns:
SpinJsonNoderepresentation of the current node
-
prop
Description copied from class:SpinJsonNodeSet a new Number property in this node.- Specified by:
propin classSpinJsonNode- Parameters:
name- the name of the new propertynewProperty- the new Number property- Returns:
SpinJsonNoderepresentation of the current node
-
prop
Description copied from class:SpinJsonNodeSet a new int property in this node.- Specified by:
propin classSpinJsonNode- Parameters:
name- the name of the new propertynewProperty- the new int property- Returns:
SpinJsonNoderepresentation of the current node
-
prop
Description copied from class:SpinJsonNodeSet a new float property in this node.- Specified by:
propin classSpinJsonNode- Parameters:
name- the name of the new propertynewProperty- the new float property- Returns:
SpinJsonNoderepresentation of the current node
-
prop
Description copied from class:SpinJsonNodeSet a new long property in this node.- Specified by:
propin classSpinJsonNode- Parameters:
name- the name of the new propertynewProperty- the new long property- Returns:
SpinJsonNoderepresentation of the current node
-
prop
Description copied from class:SpinJsonNodeSet a new boolean property in this node.- Specified by:
propin classSpinJsonNode- Parameters:
name- the name of the new propertynewProperty- the new boolean property- Returns:
SpinJsonNoderepresentation of the current node
-
prop
Description copied from class:SpinJsonNodeSet a new Boolean property in this node.- Specified by:
propin classSpinJsonNode- Parameters:
name- the name of the new propertynewProperty- the new Boolean property- Returns:
SpinJsonNoderepresentation of the current node
-
prop
Description copied from class:SpinJsonNodeSet a new List property in this node.- Specified by:
propin classSpinJsonNode- Parameters:
name- the name of the new propertynewProperty- the new List property- Returns:
SpinJsonNoderepresentation of the current node
-
propList
-
prop
Description copied from class:SpinJsonNodeSet a new Map property in this node.- Specified by:
propin classSpinJsonNode- Parameters:
name- the name of the new propertynewProperty- the new Map property- Returns:
SpinJsonNoderepresentation of the current node
-
prop
Description copied from class:SpinJsonNodeSet a new SpinJsonNode Object property in this node.- Specified by:
propin classSpinJsonNode- Parameters:
name- the name of the new propertynewProperty- the new SpinJsonNode Object property- Returns:
SpinJsonNoderepresentation of the current node
-
deleteProp
Description copied from class:SpinJsonNodeRemove a property of the given node by name.- Specified by:
deletePropin classSpinJsonNode- Parameters:
name- name of the property- Returns:
SpinJsonNoderepresentation of the current node
-
deleteProp
Description copied from class:SpinJsonNodeRemoves a number of properties by a given list of names.- Specified by:
deletePropin classSpinJsonNode- Parameters:
names- list of names- Returns:
SpinJsonNoderepresentation of the current node
-
append
Description copied from class:SpinJsonNodeAppends a object to the end of the current array node- Specified by:
appendin classSpinJsonNode- Parameters:
property- property which should be append- Returns:
SpinJsonNoderepresentation of the current node
-
insertAt
Description copied from class:SpinJsonNodeAppends an object at a specific point in an array- Specified by:
insertAtin classSpinJsonNode- Parameters:
index- Index in current node where the new property should be appended.property- Object which should be appended.- Returns:
SpinJsonNoderepresentation of the current node.
-
insertBefore
Description copied from class:SpinJsonNodeInserts an object BEFORE an specific object in an array- Specified by:
insertBeforein classSpinJsonNode- Parameters:
searchObject- Object which is searchedinsertObject- Object which will be inserted- Returns:
SpinJsonNoderepresentation of the current node
-
insertAfter
Description copied from class:SpinJsonNodeInserts an object AFTER an specific object in an array- Specified by:
insertAfterin classSpinJsonNode- Parameters:
searchObject- Object which is searchedinsertObject- Object which will be inserted- Returns:
SpinJsonNoderepresentation of the current node
-
remove
Description copied from class:SpinJsonNodeRemoves the first appearance of an object from the current array- Specified by:
removein classSpinJsonNode- Parameters:
property- object which should be deleted- Returns:
SpinJsonNoderepresentation of the current node
-
removeLast
Description copied from class:SpinJsonNodeRemoves the last appearance of an object from the current array- Specified by:
removeLastin classSpinJsonNode- Parameters:
property- object which should be deleted- Returns:
SpinJsonNoderepresentation of the current node
-
removeAt
Description copied from class:SpinJsonNoderemoves an object at the specific index of the current array- Specified by:
removeAtin classSpinJsonNode- Parameters:
index- Index of the array- Returns:
SpinJsonNoderepresentation of the current node
-
isBoolean
Description copied from class:SpinJsonNodeCheck if this node is a boolean value.- Specified by:
isBooleanin classSpinJsonNode- Returns:
- true if this node is a boolean value, false otherwise
-
boolValue
Description copied from class:SpinJsonNodeGet this node as a boolean value.- Specified by:
boolValuein classSpinJsonNode- Returns:
- the boolean value of this node
-
isNumber
Description copied from class:SpinJsonNodeCheck if this node is a number value.- Specified by:
isNumberin classSpinJsonNode- Returns:
- true if this node is a number value, false otherwise
-
numberValue
Description copied from class:SpinJsonNodeGet this node as a number value.- Specified by:
numberValuein classSpinJsonNode- Returns:
- the number value of this node
-
isString
Description copied from class:SpinJsonNodeCheck if this node is a string value.- Specified by:
isStringin classSpinJsonNode- Returns:
- true if this node is a string value, false otherwise
-
stringValue
Description copied from class:SpinJsonNodeGet this node as a string value.- Specified by:
stringValuein classSpinJsonNode- Returns:
- the string value of this node
-
isNull
Description copied from class:SpinJsonNodeCheck if this node represents a null value.- Specified by:
isNullin classSpinJsonNode- Returns:
- true if this node is a null value, false otherwise
-
isValue
Description copied from class:SpinJsonNodeCheck if this node is a value.- Specified by:
isValuein classSpinJsonNode- Returns:
- true if this node is a value, false otherwise
-
value
Description copied from class:SpinJsonNodeGets 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:
valuein classSpinJsonNode- Returns:
- the value of this node
-
isArray
Description copied from class:SpinJsonNodeCheck if this node is a array value.- Specified by:
isArrayin classSpinJsonNode- Returns:
- true if this node is a array value, false otherwise
-
elements
Description copied from class:SpinJsonNodeGet this node as list. If the current node is an array, this method returns aSpinListwhich 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:
elementsin classSpinJsonNode- Returns:
- the list value of this node
-
fieldNames
Description copied from class:SpinJsonNodeGet the field names of this node (i.e. the property names).- Specified by:
fieldNamesin classSpinJsonNode- Returns:
- the list of field names
-
getNodeType
public com.fasterxml.jackson.databind.node.JsonNodeType getNodeType() -
jsonPath
Description copied from class:SpinJsonNodeCreates a JsonPath query on this element.- Specified by:
jsonPathin 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:
mapToin 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:
mapToin 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
-