Class JacksonJsonNode
- java.lang.Object
-
- org.camunda.spin.Spin<SpinJsonNode>
-
- org.camunda.spin.json.SpinJsonNode
-
- org.camunda.spin.impl.json.jackson.JacksonJsonNode
-
public class JacksonJsonNode extends SpinJsonNode
Wrapper for a Jackson Json Tree Node.- Author:
- Thorben Lindhauer, Stefan Hentschel
-
-
Field Summary
Fields Modifier and Type Field Description protected JacksonJsonDataFormatdataFormatprotected com.fasterxml.jackson.databind.JsonNodejsonNode
-
Constructor Summary
Constructors Constructor Description JacksonJsonNode(com.fasterxml.jackson.databind.JsonNode jsonNode, JacksonJsonDataFormat dataFormat)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SpinJsonNodeappend(java.lang.Object property)Appends a object to the end of the current array nodejava.lang.BooleanboolValue()Get this node as a boolean value.booleancontains(java.lang.Object searchObject)Returnstrueif the array contains the specified object.SpinJsonNodedeleteProp(java.lang.String name)Remove a property of the given node by name.SpinJsonNodedeleteProp(java.util.List<java.lang.String> names)Removes a number of properties by a given list of names.SpinList<SpinJsonNode>elements()Get this node as list.java.util.List<java.lang.String>fieldNames()Get the field names of this node (i.e.protected java.lang.IntegergetCorrectIndex(java.lang.Integer index)fetch correct array index if index is less than 0 ArrayNode will convert all negative integers into 0...java.lang.StringgetDataFormatName()Provides the name of the dataformat used by this spin.com.fasterxml.jackson.databind.node.JsonNodeTypegetNodeType()booleanhasProp(java.lang.String name)Check if this node has a property with the given name.java.lang.IntegerindexOf(java.lang.Object searchObject)Fetches the first index of the searched object in an array.SpinJsonNodeinsertAfter(java.lang.Object searchObject, java.lang.Object insertObject)Inserts an object AFTER an specific object in an arraySpinJsonNodeinsertAt(int index, java.lang.Object property)Appends an object at a specific point in an arraySpinJsonNodeinsertBefore(java.lang.Object searchObject, java.lang.Object insertObject)Inserts an object BEFORE an specific object in an arrayjava.lang.BooleanisArray()Check if this node is a array value.java.lang.BooleanisBoolean()Check if this node is a boolean value.java.lang.BooleanisNull()Check if this node represents a null value.java.lang.BooleanisNumber()Check if this node is a number value.booleanisObject()Check if this node is an object node.java.lang.BooleanisString()Check if this node is a string value.java.lang.BooleanisValue()Check if this node is a value.SpinJsonPathQueryjsonPath(java.lang.String expression)Creates a JsonPath query on this element.java.lang.IntegerlastIndexOf(java.lang.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> CmapTo(java.lang.Class<C> 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> CmapTo(java.lang.String type)Maps the json represented by this object to a java object of the given type.java.lang.NumbernumberValue()Get this node as a number value.SpinJsonNodeprop(java.lang.String name)Get the property of this node with the given name.SpinJsonNodeprop(java.lang.String name, boolean newProperty)Set a new boolean property in this node.SpinJsonNodeprop(java.lang.String name, float newProperty)Set a new float property in this node.SpinJsonNodeprop(java.lang.String name, int newProperty)Set a new int property in this node.SpinJsonNodeprop(java.lang.String name, long newProperty)Set a new long property in this node.SpinJsonNodeprop(java.lang.String name, java.lang.Boolean newProperty)Set a new Boolean property in this node.SpinJsonNodeprop(java.lang.String name, java.lang.Number newProperty)Set a new Number property in this node.SpinJsonNodeprop(java.lang.String name, java.lang.String newProperty)Set a new String property in this node.SpinJsonNodeprop(java.lang.String name, java.util.List<java.lang.Object> newProperty)Set a new List property in this node.SpinJsonNodeprop(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> newProperty)Set a new Map property in this node.SpinJsonNodeprop(java.lang.String name, SpinJsonNode newProperty)Set a new SpinJsonNode Object property in this node.SpinJsonNodepropList(java.lang.String name, java.util.List<java.lang.Object> newProperty)SpinJsonNoderemove(java.lang.Object property)Removes the first appearance of an object from the current arraySpinJsonNoderemoveAt(int index)removes an object at the specific index of the current arraySpinJsonNoderemoveLast(java.lang.Object property)Removes the last appearance of an object from the current arrayjava.lang.StringstringValue()Get this node as a string value.java.lang.StringtoString()Returns the wrapped object as string representation.com.fasterxml.jackson.databind.JsonNodeunwrap()Return the wrapped object.java.lang.Objectvalue()Gets the actual value of the node, in case it is a Boolean/String/Number/Null node.voidwriteToWriter(java.io.Writer writer)Writes the wrapped object to a existing writer.
-
-
-
Field Detail
-
jsonNode
protected final com.fasterxml.jackson.databind.JsonNode jsonNode
-
dataFormat
protected final JacksonJsonDataFormat dataFormat
-
-
Constructor Detail
-
JacksonJsonNode
public JacksonJsonNode(com.fasterxml.jackson.databind.JsonNode jsonNode, JacksonJsonDataFormat dataFormat)
-
-
Method Detail
-
getDataFormatName
public java.lang.String 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
public java.lang.String toString()
Description copied from class:SpinReturns the wrapped object as string representation.- Specified by:
toStringin classSpin<SpinJsonNode>- Returns:
- the string representation
-
writeToWriter
public void writeToWriter(java.io.Writer writer)
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
protected java.lang.Integer getCorrectIndex(java.lang.Integer index)
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
public java.lang.Integer indexOf(java.lang.Object searchObject)
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
public java.lang.Integer lastIndexOf(java.lang.Object searchObject)
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
public boolean contains(java.lang.Object searchObject)
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
public boolean hasProp(java.lang.String name)
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
public SpinJsonNode prop(java.lang.String name)
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
public SpinJsonNode prop(java.lang.String name, java.lang.String newProperty)
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
public SpinJsonNode prop(java.lang.String name, java.lang.Number newProperty)
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
public SpinJsonNode prop(java.lang.String name, int newProperty)
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
public SpinJsonNode prop(java.lang.String name, float newProperty)
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
public SpinJsonNode prop(java.lang.String name, long newProperty)
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
public SpinJsonNode prop(java.lang.String name, boolean newProperty)
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
public SpinJsonNode prop(java.lang.String name, java.lang.Boolean newProperty)
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
public SpinJsonNode prop(java.lang.String name, java.util.List<java.lang.Object> newProperty)
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
public SpinJsonNode propList(java.lang.String name, java.util.List<java.lang.Object> newProperty)
-
prop
public SpinJsonNode prop(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> newProperty)
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
public SpinJsonNode prop(java.lang.String name, SpinJsonNode newProperty)
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
public SpinJsonNode deleteProp(java.lang.String name)
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
public SpinJsonNode deleteProp(java.util.List<java.lang.String> names)
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
public SpinJsonNode append(java.lang.Object property)
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
public SpinJsonNode insertAt(int index, java.lang.Object property)
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
public SpinJsonNode insertBefore(java.lang.Object searchObject, java.lang.Object insertObject)
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
public SpinJsonNode insertAfter(java.lang.Object searchObject, java.lang.Object insertObject)
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
public SpinJsonNode remove(java.lang.Object property)
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
public SpinJsonNode removeLast(java.lang.Object property)
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
public SpinJsonNode removeAt(int index)
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
public java.lang.Boolean 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
public java.lang.Boolean boolValue()
Description copied from class:SpinJsonNodeGet this node as a boolean value.- Specified by:
boolValuein classSpinJsonNode- Returns:
- the boolean value of this node
-
isNumber
public java.lang.Boolean 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
public java.lang.Number numberValue()
Description copied from class:SpinJsonNodeGet this node as a number value.- Specified by:
numberValuein classSpinJsonNode- Returns:
- the number value of this node
-
isString
public java.lang.Boolean 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
public java.lang.String stringValue()
Description copied from class:SpinJsonNodeGet this node as a string value.- Specified by:
stringValuein classSpinJsonNode- Returns:
- the string value of this node
-
isNull
public java.lang.Boolean 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
public java.lang.Boolean 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
public java.lang.Object 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
public java.lang.Boolean 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
public SpinList<SpinJsonNode> 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
public java.util.List<java.lang.String> 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
public SpinJsonPathQuery jsonPath(java.lang.String expression)
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
public <C> C mapTo(java.lang.Class<C> 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.- 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
public <C> C mapTo(java.lang.String type)
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
-
-