public class JsonRepresentation extends Object
JsonNode that provides some additional helper
methods.| Modifier and Type | Class and Description |
|---|---|
static interface |
JsonRepresentation.HasExtensions |
static interface |
JsonRepresentation.HasLinks |
static interface |
JsonRepresentation.HasLinkToSelf |
static interface |
JsonRepresentation.HasLinkToUp |
| Modifier and Type | Field and Description |
|---|---|
static org.joda.time.format.DateTimeFormatter |
_HHmmss |
protected org.codehaus.jackson.JsonNode |
jsonNode |
static org.joda.time.format.DateTimeFormatter |
yyyyMMdd |
static org.joda.time.format.DateTimeFormatter |
yyyyMMddTHHmmssZ |
| Constructor and Description |
|---|
JsonRepresentation(org.codehaus.jackson.JsonNode jsonNode) |
| Modifier and Type | Method and Description |
|---|---|
JsonRepresentation |
arrayAdd(boolean value) |
JsonRepresentation |
arrayAdd(double value) |
JsonRepresentation |
arrayAdd(float value) |
JsonRepresentation |
arrayAdd(int value) |
JsonRepresentation |
arrayAdd(org.codehaus.jackson.JsonNode value) |
JsonRepresentation |
arrayAdd(JsonRepresentation value) |
JsonRepresentation |
arrayAdd(long value) |
JsonRepresentation |
arrayAdd(Object value) |
JsonRepresentation |
arrayAdd(String value) |
JsonRepresentation |
arrayGet(int i) |
Iterable<JsonRepresentation> |
arrayIterable() |
<T> Iterable<T> |
arrayIterable(Class<T> requiredType) |
Iterator<JsonRepresentation> |
arrayIterator() |
<T> Iterator<T> |
arrayIterator(Class<T> requiredType) |
JsonRepresentation |
arraySetElementAt(int i,
JsonRepresentation objectRepr) |
<T extends JsonRepresentation> |
as(Class<T> cls)
Convenience to simply "downcast".
|
String |
asArg() |
JsonRepresentation |
asArray() |
protected org.codehaus.jackson.node.ArrayNode |
asArrayNode()
Convert underlying representation into an array.
|
BigDecimal |
asBigDecimal()
Use
isBigDecimal() to check first, if required. |
BigDecimal |
asBigDecimal(String format)
Use
isBigDecimal() to check first, if required. |
BigInteger |
asBigInteger()
Use
isBigInteger() to check first, if required. |
BigInteger |
asBigInteger(String format) |
Boolean |
asBoolean()
Use
isBoolean() to check first, if required. |
Byte |
asByte()
Use
isIntegralNumber() to test if number (it is not possible to check if a byte, however). |
Character |
asChar()
Use
isString() to check if string (it is not possible to check if a character, however). |
Date |
asDate() |
Date |
asDateTime() |
Double |
asDouble()
Use
isDouble() to check first, if required. |
Float |
asFloat()
Use
isNumber() to test if number (it is not possible to check if a float, however). |
InputStream |
asInputStream() |
Integer |
asInt()
Use
isInt() to check first, if required. |
org.codehaus.jackson.JsonNode |
asJsonNode() |
LinkRepresentation |
asLink()
Use
isLink() to check first, if required. |
Long |
asLong()
Use
isLong() to check first, if required. |
JsonRepresentation |
asMap() |
JsonRepresentation |
asNull()
Either returns a
JsonRepresentation that indicates that the
wrapped node has null value (ie
isNull()), or returns null if there
was no node with the provided path. |
Number |
asNumber() |
protected org.codehaus.jackson.node.ObjectNode |
asObjectNode()
Convert underlying representation into an object (map).
|
Short |
asShort()
Use
isIntegralNumber() to check if number (it is not possible to check if a short, however). |
String |
asString()
Use
isString() to check first, if required. |
Date |
asTime() |
String |
asUrlEncoded() |
JsonRepresentation |
ensureArray()
A reciprocal of the behaviour of the automatic dereferencing of arrays
that occurs when there is only a single instance.
|
boolean |
equals(Object obj) |
JsonRepresentation |
getArray(String path) |
JsonRepresentation |
getArrayEnsured(String path) |
BigDecimal |
getBigDecimal(String path)
Use
isBigDecimal(String) to check first, if required. |
BigDecimal |
getBigDecimal(String path,
String formatRequested)
Use
isBigDecimal(String) to check first, if required. |
BigInteger |
getBigInteger(String path)
Use
isBigInteger(String) to check first, if required. |
BigInteger |
getBigInteger(String path,
String formatRequested)
Use
isBigInteger(String) to check first, if required. |
Boolean |
getBoolean(String path)
Use
isBoolean(String) to check first, if required. |
Byte |
getByte(String path)
Use
isIntegralNumber(String) to test if number (it is not possible to check if a byte, however). |
Character |
getChar(String path)
Use
isString(String) to check if string (it is not possible to check if a character, however). |
Date |
getDate(String path) |
Date |
getDateTime(String path) |
Double |
getDouble(String path)
Use
isDouble(String) to check first, if required. |
Float |
getFloat(String path)
Use
isDecimal(String) to test if a decimal value |
Integer |
getInt(String path)
Use
isInt(String) to check first, if required. |
LinkRepresentation |
getLink(String path)
Use
isLink(String) to check first, if required. |
Long |
getLong(String path)
Use
isLong(String) to check first, if required. |
JsonRepresentation |
getMap(String path) |
JsonRepresentation |
getNull(String path)
Either returns a
JsonRepresentation that indicates that the
wrapped node has null value (ie
isNull()), or returns null if there
was no node with the provided path. |
JsonRepresentation |
getRepresentation(String pathTemplate,
Object... args) |
Short |
getShort(String path)
Use
isIntegralNumber(String) to check if number (it is not possible to check if a short, however). |
String |
getString(String path)
Use
isString(String) to check first, if required. |
Date |
getTime(String path) |
int |
hashCode() |
boolean |
isArray() |
boolean |
isArray(String path) |
boolean |
isBigDecimal() |
boolean |
isBigDecimal(String path) |
boolean |
isBigInteger() |
boolean |
isBigInteger(String path) |
boolean |
isBoolean() |
boolean |
isBoolean(String path) |
boolean |
isDecimal() |
boolean |
isDecimal(String path) |
boolean |
isDouble()
Deprecated.
- use
isDecimal() |
boolean |
isDouble(String path)
Deprecated.
- use
isDecimal(String) |
boolean |
isInt() |
boolean |
isInt(String path) |
boolean |
isIntegralNumber()
Is a long, an int or a
BigInteger. |
boolean |
isIntegralNumber(String path)
Is a long, an int or a
BigInteger. |
boolean |
isLink() |
boolean |
isLink(org.codehaus.jackson.JsonNode node) |
boolean |
isLink(String path) |
boolean |
isLong() |
boolean |
isLong(String path) |
boolean |
isMap() |
boolean |
isMap(String path) |
boolean |
isNull() |
Boolean |
isNull(String path)
Indicates that the wrapped node has null value (ie
isNull()), or returns null if there
was no node with the provided path. |
boolean |
isNumber() |
boolean |
isNumber(String path) |
boolean |
isString() |
boolean |
isString(String path) |
boolean |
isValue()
Node is a value (nb: could be
null). |
boolean |
mapHas(String key) |
Iterable<Map.Entry<String,JsonRepresentation>> |
mapIterable() |
Iterator<Map.Entry<String,JsonRepresentation>> |
mapIterator() |
JsonRepresentation |
mapPut(Iterable<Map.Entry<String,JsonRepresentation>> entries) |
JsonRepresentation |
mapPut(Map.Entry<String,JsonRepresentation> entry) |
JsonRepresentation |
mapPut(String key,
BigDecimal value) |
JsonRepresentation |
mapPut(String key,
BigInteger value) |
JsonRepresentation |
mapPut(String key,
boolean value) |
JsonRepresentation |
mapPut(String key,
Boolean value) |
JsonRepresentation |
mapPut(String key,
byte value) |
JsonRepresentation |
mapPut(String key,
Byte value) |
JsonRepresentation |
mapPut(String key,
char value) |
JsonRepresentation |
mapPut(String key,
Character value) |
JsonRepresentation |
mapPut(String key,
double value) |
JsonRepresentation |
mapPut(String key,
Double value) |
JsonRepresentation |
mapPut(String key,
float value) |
JsonRepresentation |
mapPut(String key,
Float value) |
JsonRepresentation |
mapPut(String key,
int value) |
JsonRepresentation |
mapPut(String key,
Integer value) |
JsonRepresentation |
mapPut(String key,
org.codehaus.jackson.JsonNode value) |
JsonRepresentation |
mapPut(String key,
JsonRepresentation value) |
JsonRepresentation |
mapPut(String key,
List<Object> value) |
JsonRepresentation |
mapPut(String key,
long value) |
JsonRepresentation |
mapPut(String key,
Long value) |
JsonRepresentation |
mapPut(String key,
Object value) |
JsonRepresentation |
mapPut(String key,
short value) |
JsonRepresentation |
mapPut(String key,
Short value) |
JsonRepresentation |
mapPut(String key,
String value) |
LinkRepresentation |
mapValueAsLink()
Convert a representation that contains a single node representing a link
into a
LinkRepresentation. |
static JsonRepresentation |
newArray() |
static JsonRepresentation |
newArray(int initialSize) |
static JsonRepresentation |
newMap(String... keyValuePairs) |
int |
size() |
String |
toString() |
protected final org.codehaus.jackson.JsonNode jsonNode
public static final org.joda.time.format.DateTimeFormatter yyyyMMdd
public static final org.joda.time.format.DateTimeFormatter yyyyMMddTHHmmssZ
public static final org.joda.time.format.DateTimeFormatter _HHmmss
public JsonRepresentation(org.codehaus.jackson.JsonNode jsonNode)
public static JsonRepresentation newMap(String... keyValuePairs)
public static JsonRepresentation newArray()
public static JsonRepresentation newArray(int initialSize)
public org.codehaus.jackson.JsonNode asJsonNode()
public int size()
public JsonRepresentation getRepresentation(String pathTemplate, Object... args)
public boolean isArray()
public JsonRepresentation getArray(String path)
public JsonRepresentation asArray()
public JsonRepresentation getArrayEnsured(String path)
public boolean isMap()
public JsonRepresentation getMap(String path)
public JsonRepresentation asMap()
public boolean isNumber()
public boolean isIntegralNumber(String path)
BigInteger.public boolean isIntegralNumber()
BigInteger.public Date getDateTime(String path)
public Date asDateTime()
public boolean isBoolean()
public Boolean getBoolean(String path)
isBoolean(String) to check first, if required.public Boolean asBoolean()
isBoolean() to check first, if required.public Byte getByte(String path)
isIntegralNumber(String) to test if number (it is not possible to check if a byte, however).public Byte asByte()
isIntegralNumber() to test if number (it is not possible to check if a byte, however).public Short getShort(String path)
isIntegralNumber(String) to check if number (it is not possible to check if a short, however).public Short asShort()
isIntegralNumber() to check if number (it is not possible to check if a short, however).public Character getChar(String path)
isString(String) to check if string (it is not possible to check if a character, however).public Character asChar()
isString() to check if string (it is not possible to check if a character, however).public boolean isInt()
public Integer getInt(String path)
isInt(String) to check first, if required.public boolean isLong()
public Long getLong(String path)
isLong(String) to check first, if required.public Float getFloat(String path)
isDecimal(String) to test if a decimal valuepublic Float asFloat()
isNumber() to test if number (it is not possible to check if a float, however).public boolean isDecimal()
@Deprecated public boolean isDouble(String path)
isDecimal(String)@Deprecated public boolean isDouble()
isDecimal()public Double getDouble(String path)
isDouble(String) to check first, if required.public Double asDouble()
isDouble() to check first, if required.public boolean isBigInteger(String path)
public boolean isBigInteger()
public BigInteger getBigInteger(String path)
isBigInteger(String) to check first, if required.public BigInteger getBigInteger(String path, String formatRequested)
isBigInteger(String) to check first, if required.public BigInteger asBigInteger()
isBigInteger() to check first, if required.public BigInteger asBigInteger(String format)
public boolean isBigDecimal(String path)
public boolean isBigDecimal()
public BigDecimal getBigDecimal(String path)
isBigDecimal(String) to check first, if required.public BigDecimal getBigDecimal(String path, String formatRequested)
isBigDecimal(String) to check first, if required.public BigDecimal asBigDecimal()
isBigDecimal() to check first, if required.public BigDecimal asBigDecimal(String format)
isBigDecimal() to check first, if required.public boolean isString()
public String getString(String path)
isString(String) to check first, if required.public String asString()
isString() to check first, if required.public boolean isLink()
public boolean isLink(org.codehaus.jackson.JsonNode node)
public LinkRepresentation getLink(String path)
isLink(String) to check first, if required.public LinkRepresentation asLink()
isLink() to check first, if required.public boolean isNull()
public Boolean isNull(String path)
isNull()), or returns null if there
was no node with the provided path.public JsonRepresentation getNull(String path)
JsonRepresentation that indicates that the
wrapped node has null value (ie
isNull()), or returns null if there
was no node with the provided path.
Use isNull(String) to check first, if required.
public JsonRepresentation asNull()
JsonRepresentation that indicates that the
wrapped node has null value (ie
isNull()), or returns null if there
was no node with the provided path.
Use isNull() to check first, if required.
public LinkRepresentation mapValueAsLink()
LinkRepresentation.public InputStream asInputStream()
protected org.codehaus.jackson.node.ArrayNode asArrayNode()
protected org.codehaus.jackson.node.ObjectNode asObjectNode()
public <T extends JsonRepresentation> T as(Class<T> cls)
In fact, the method creates a new instance of the specified type, which
shares the underlying jsonNode.
public String asUrlEncoded()
public JsonRepresentation arrayAdd(Object value)
public JsonRepresentation arrayAdd(JsonRepresentation value)
public JsonRepresentation arrayAdd(String value)
public JsonRepresentation arrayAdd(org.codehaus.jackson.JsonNode value)
public JsonRepresentation arrayAdd(long value)
public JsonRepresentation arrayAdd(int value)
public JsonRepresentation arrayAdd(double value)
public JsonRepresentation arrayAdd(float value)
public JsonRepresentation arrayAdd(boolean value)
public Iterable<JsonRepresentation> arrayIterable()
public <T> Iterable<T> arrayIterable(Class<T> requiredType)
public Iterator<JsonRepresentation> arrayIterator()
public <T> Iterator<T> arrayIterator(Class<T> requiredType)
public JsonRepresentation arrayGet(int i)
public JsonRepresentation arraySetElementAt(int i, JsonRepresentation objectRepr)
public JsonRepresentation mapPut(String key, List<Object> value)
public JsonRepresentation mapPut(String key, Object value)
public JsonRepresentation mapPut(String key, JsonRepresentation value)
public JsonRepresentation mapPut(String key, String value)
public JsonRepresentation mapPut(String key, org.codehaus.jackson.JsonNode value)
public JsonRepresentation mapPut(String key, byte value)
public JsonRepresentation mapPut(String key, Byte value)
public JsonRepresentation mapPut(String key, short value)
public JsonRepresentation mapPut(String key, Short value)
public JsonRepresentation mapPut(String key, int value)
public JsonRepresentation mapPut(String key, Integer value)
public JsonRepresentation mapPut(String key, long value)
public JsonRepresentation mapPut(String key, Long value)
public JsonRepresentation mapPut(String key, float value)
public JsonRepresentation mapPut(String key, Float value)
public JsonRepresentation mapPut(String key, double value)
public JsonRepresentation mapPut(String key, Double value)
public JsonRepresentation mapPut(String key, boolean value)
public JsonRepresentation mapPut(String key, Boolean value)
public JsonRepresentation mapPut(String key, char value)
public JsonRepresentation mapPut(String key, Character value)
public JsonRepresentation mapPut(String key, BigInteger value)
public JsonRepresentation mapPut(Iterable<Map.Entry<String,JsonRepresentation>> entries)
public JsonRepresentation mapPut(Map.Entry<String,JsonRepresentation> entry)
public JsonRepresentation mapPut(String key, BigDecimal value)
public Iterable<Map.Entry<String,JsonRepresentation>> mapIterable()
public Iterator<Map.Entry<String,JsonRepresentation>> mapIterator()
public JsonRepresentation ensureArray()
toJsonNode(List)Copyright © 2010–2014 The Apache Software Foundation. All rights reserved.