org.camunda.spin.impl.json.jackson.query
Class JsonPathJacksonProvider

java.lang.Object
  extended by org.camunda.spin.impl.json.jackson.query.JsonPathJacksonProvider
All Implemented Interfaces:
com.jayway.jsonpath.spi.JsonProvider, com.jayway.jsonpath.spi.MappingProvider

public class JsonPathJacksonProvider
extends Object
implements com.jayway.jsonpath.spi.MappingProvider, com.jayway.jsonpath.spi.JsonProvider

A copy of com.jayway.jsonpath.spi.impl.JacksonProvider which allows a) to use com.fasterxml.jackson b) to pass in a custom ObjectMapper

Author:
Kalle Stenflo, Daniel Meyer

Field Summary
protected  com.fasterxml.jackson.databind.ObjectMapper objectMapper
           
 
Constructor Summary
JsonPathJacksonProvider()
           
JsonPathJacksonProvider(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
           
 
Method Summary
 Object clone(Object obj)
           
<T> T
convertValue(Object fromValue, Class<T> toValueType)
           
<T extends Collection<E>,E>
T
convertValue(Object fromValue, Class<T> collectionType, Class<E> elementType)
           
 List<Object> createArray()
           
 Map<String,Object> createMap()
           
 com.jayway.jsonpath.spi.Mode getMode()
           
 Object getProperty(Object obj, Object key)
          Extracts a value from an object or array
 Collection<String> getPropertyKeys(Object obj)
          Returns the keys from the given object or the indexes from an array
 boolean isArray(Object obj)
          checks if object is an array
 boolean isContainer(Object obj)
          checks if object is a map or an array
 boolean isMap(Object obj)
          checks if object is a map (i.e. no array)
 int length(Object obj)
          Get the length of an array or object
 Object parse(InputStream jsonStream)
           
 Object parse(Reader jsonReader)
           
 Object parse(String json)
           
 void setProperty(Object obj, Object key, Object value)
          Sets a value in an object or array
 Iterable<Object> toIterable(Object obj)
          Converts given object to an Iterable
 String toJson(Object obj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objectMapper

protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
Constructor Detail

JsonPathJacksonProvider

public JsonPathJacksonProvider()

JsonPathJacksonProvider

public JsonPathJacksonProvider(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Method Detail

getMode

public com.jayway.jsonpath.spi.Mode getMode()
Specified by:
getMode in interface com.jayway.jsonpath.spi.JsonProvider

parse

public Object parse(String json)
             throws com.jayway.jsonpath.InvalidJsonException
Specified by:
parse in interface com.jayway.jsonpath.spi.JsonProvider
Throws:
com.jayway.jsonpath.InvalidJsonException

parse

public Object parse(Reader jsonReader)
             throws com.jayway.jsonpath.InvalidJsonException
Specified by:
parse in interface com.jayway.jsonpath.spi.JsonProvider
Throws:
com.jayway.jsonpath.InvalidJsonException

parse

public Object parse(InputStream jsonStream)
             throws com.jayway.jsonpath.InvalidJsonException
Specified by:
parse in interface com.jayway.jsonpath.spi.JsonProvider
Throws:
com.jayway.jsonpath.InvalidJsonException

toJson

public String toJson(Object obj)
Specified by:
toJson in interface com.jayway.jsonpath.spi.JsonProvider

createMap

public Map<String,Object> createMap()
Specified by:
createMap in interface com.jayway.jsonpath.spi.JsonProvider

createArray

public List<Object> createArray()
Specified by:
createArray in interface com.jayway.jsonpath.spi.JsonProvider

convertValue

public <T> T convertValue(Object fromValue,
                          Class<T> toValueType)
               throws IllegalArgumentException
Specified by:
convertValue in interface com.jayway.jsonpath.spi.MappingProvider
Throws:
IllegalArgumentException

convertValue

public <T extends Collection<E>,E> T convertValue(Object fromValue,
                                                  Class<T> collectionType,
                                                  Class<E> elementType)
                                     throws IllegalArgumentException
Specified by:
convertValue in interface com.jayway.jsonpath.spi.MappingProvider
Throws:
IllegalArgumentException

clone

public Object clone(Object obj)
Specified by:
clone in interface com.jayway.jsonpath.spi.JsonProvider

isContainer

public boolean isContainer(Object obj)
checks if object is a map or an array

Specified by:
isContainer in interface com.jayway.jsonpath.spi.JsonProvider
Parameters:
obj - object to check
Returns:
true if obj is a map or an array

isArray

public boolean isArray(Object obj)
checks if object is an array

Specified by:
isArray in interface com.jayway.jsonpath.spi.JsonProvider
Parameters:
obj - object to check
Returns:
true if obj is an array

getProperty

public Object getProperty(Object obj,
                          Object key)
Extracts a value from an object or array

Specified by:
getProperty in interface com.jayway.jsonpath.spi.JsonProvider
Parameters:
obj - an array or an object
key - a String key or a numerical index
Returns:
the entry at the given key, i.e. obj[key]

setProperty

public void setProperty(Object obj,
                        Object key,
                        Object value)
Sets a value in an object or array

Specified by:
setProperty in interface com.jayway.jsonpath.spi.JsonProvider
Parameters:
obj - an array or an object
key - a String key or a numerical index
value - the value to set

isMap

public boolean isMap(Object obj)
checks if object is a map (i.e. no array)

Specified by:
isMap in interface com.jayway.jsonpath.spi.JsonProvider
Parameters:
obj - object to check
Returns:
true if the object is a map

getPropertyKeys

public Collection<String> getPropertyKeys(Object obj)
Returns the keys from the given object or the indexes from an array

Specified by:
getPropertyKeys in interface com.jayway.jsonpath.spi.JsonProvider
Parameters:
obj - an array or an object
Returns:
the keys for an object or the indexes for an array

length

public int length(Object obj)
Get the length of an array or object

Specified by:
length in interface com.jayway.jsonpath.spi.JsonProvider
Parameters:
obj - an array or an object
Returns:
the number of entries in the array or object

toIterable

public Iterable<Object> toIterable(Object obj)
Converts given object to an Iterable

Specified by:
toIterable in interface com.jayway.jsonpath.spi.JsonProvider
Parameters:
obj - an array or an object
Returns:
the entries for an array or the values for a map


Copyright © 2016 camunda services GmbH. All rights reserved.