public class JSONNavi<T>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private java.lang.Object |
current |
private static JSONStyle |
ERROR_COMPRESS |
private boolean |
failure |
private java.lang.String |
failureMessage |
private JsonReaderI<? super T> |
mapper |
private java.lang.Object |
missingKey |
private java.util.Stack<java.lang.Object> |
path |
private boolean |
readonly |
private T |
root |
private java.util.Stack<java.lang.Object> |
stack |
| Constructor and Description |
|---|
JSONNavi(JsonReaderI<? super T> mapper) |
JSONNavi(java.lang.String json) |
JSONNavi(java.lang.String json,
java.lang.Class<T> mapTo) |
JSONNavi(java.lang.String json,
JsonReaderI<T> mapper) |
| Modifier and Type | Method and Description |
|---|---|
private java.util.List<java.lang.Object> |
a(java.lang.Object obj)
internal cast to List
|
JSONNavi<T> |
add(java.lang.Object... values)
add value to the current arrays
|
JSONNavi<T> |
array()
Set current value as Json Array You can also skip this call Arrays can be
create automatically.
|
boolean |
asBoolean()
get the current value as boolean if the current Object is null or is not
a boolean return false
|
java.lang.Boolean |
asBooleanObj()
get the current object value as Boolean if the current Object is not a
Boolean return null.
|
double |
asDouble()
get the current value as double if the current Object is null return
Double.NaN
|
java.lang.Double |
asDoubleObj()
get the current object value as Double if the current Double can not be
cast as Integer return null.
|
double |
asFloat()
get the current value as float if the current Object is null return
Float.NaN
|
java.lang.Float |
asFloatObj()
get the current object value as Float if the current Float can not be
cast as Integer return null.
|
int |
asInt()
get the current value as int if the current Object is null return 0
|
java.lang.Integer |
asIntegerObj()
get the current object value as Integer if the current Object can not be
cast as Integer return null.
|
long |
asLong()
get the current value as long if the current Object is null return 0
|
java.lang.Long |
asLongObj()
get the current object value as Long if the current Object can not be
cast as Long return null.
|
java.lang.String |
asString()
get the current object value as String if the current Object is null
return null.
|
JSONNavi<?> |
at(int index)
Access to the index position.
|
JSONNavi<?> |
at(java.lang.String key) |
JSONNavi<?> |
atNext()
Access to last + 1 the index position.
|
private JSONNavi<?> |
failure(java.lang.String err,
java.lang.Object jPathPostfix)
Internally log errors.
|
java.lang.Object |
get(int index) |
java.lang.Object |
get(java.lang.String key) |
java.lang.Object |
getCurrentObject() |
double |
getDouble(java.lang.String key) |
int |
getInt(java.lang.String key) |
java.lang.Integer |
getInteger(java.lang.String key) |
java.lang.String |
getJPath() |
java.util.Collection<java.lang.String> |
getKeys() |
T |
getRoot() |
int |
getSize() |
java.lang.String |
getString(java.lang.String key) |
boolean |
hasFailure() |
boolean |
hasKey(java.lang.String key) |
boolean |
isArray()
is the current node is an array
|
private boolean |
isArray(java.lang.Object obj)
check if Object is an Array
|
boolean |
isObject()
is the current node is an object
|
private boolean |
isObject(java.lang.Object obj)
check if Object is an Map
|
static JSONNavi<JSONAwareEx> |
newInstance() |
static JSONNavi<JSONArray> |
newInstanceArray() |
static JSONNavi<JSONObject> |
newInstanceObject() |
private java.util.Map<java.lang.String,java.lang.Object> |
o(java.lang.Object obj)
internal cast to Map
|
JSONNavi<T> |
object()
Set current value as Json Object You can also skip this call, Objects can
be create automatically.
|
JSONNavi<T> |
root()
return to root node
|
JSONNavi<T> |
set(java.lang.Boolean bool)
set current value as Boolean
|
JSONNavi<T> |
set(java.lang.Number num)
set current value as Number
|
JSONNavi<T> |
set(java.lang.String text)
set current value as String
|
JSONNavi<T> |
set(java.lang.String key,
double value)
write an value in the current object
|
JSONNavi<T> |
set(java.lang.String key,
float value)
write an value in the current object
|
JSONNavi<T> |
set(java.lang.String key,
int value)
write an value in the current object
|
JSONNavi<T> |
set(java.lang.String key,
long value)
write an value in the current object
|
JSONNavi<T> |
set(java.lang.String key,
java.lang.Number value) |
JSONNavi<T> |
set(java.lang.String key,
java.lang.String value) |
private void |
store()
internal store current Object in current non existing localization
|
java.lang.String |
toString()
return the Object as a Json String
|
java.lang.String |
toString(JSONStyle compression)
return the Object as a Json String
|
JSONNavi<?> |
up()
Move one level up in Json tree.
|
JSONNavi<?> |
up(int level)
call up() level times.
|
private JsonReaderI<? super T> mapper
private T root
private java.util.Stack<java.lang.Object> stack
private java.util.Stack<java.lang.Object> path
private java.lang.Object current
private boolean failure
private java.lang.String failureMessage
private boolean readonly
private java.lang.Object missingKey
private static final JSONStyle ERROR_COMPRESS
public JSONNavi(JsonReaderI<? super T> mapper)
public JSONNavi(java.lang.String json)
public JSONNavi(java.lang.String json,
JsonReaderI<T> mapper)
public JSONNavi(java.lang.String json,
java.lang.Class<T> mapTo)
public static JSONNavi<JSONAwareEx> newInstance()
public static JSONNavi<JSONObject> newInstanceObject()
public boolean hasFailure()
public java.lang.Object getCurrentObject()
public java.util.Collection<java.lang.String> getKeys()
public int getSize()
public java.lang.String getString(java.lang.String key)
public int getInt(java.lang.String key)
public java.lang.Integer getInteger(java.lang.String key)
public double getDouble(java.lang.String key)
public boolean hasKey(java.lang.String key)
public JSONNavi<?> at(java.lang.String key)
public java.lang.Object get(java.lang.String key)
public java.lang.Object get(int index)
public JSONNavi<T> set(java.lang.String key, long value)
key - key to accessvalue - new valuepublic JSONNavi<T> set(java.lang.String key, int value)
key - key to accessvalue - new valuepublic JSONNavi<T> set(java.lang.String key, double value)
key - key to accessvalue - new valuepublic JSONNavi<T> set(java.lang.String key, float value)
key - key to accessvalue - new valuepublic JSONNavi<T> add(java.lang.Object... values)
values - to addpublic java.lang.String asString()
public double asDouble()
public java.lang.Double asDoubleObj()
public double asFloat()
public java.lang.Float asFloatObj()
public int asInt()
public java.lang.Integer asIntegerObj()
public long asLong()
public java.lang.Long asLongObj()
public boolean asBoolean()
public java.lang.Boolean asBooleanObj()
public JSONNavi<T> object()
public JSONNavi<T> array()
public T getRoot()
private void store()
public boolean isArray()
public boolean isObject()
private boolean isArray(java.lang.Object obj)
private boolean isObject(java.lang.Object obj)
private java.util.List<java.lang.Object> a(java.lang.Object obj)
private java.util.Map<java.lang.String,java.lang.Object> o(java.lang.Object obj)
public JSONNavi<?> at(int index)
index - 0 based desired position in Arraypublic JSONNavi<?> atNext()
public JSONNavi<?> up(int level)
level - number of parent move.public JSONNavi<?> up()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(JSONStyle compression)
compression - private JSONNavi<?> failure(java.lang.String err, java.lang.Object jPathPostfix)
public java.lang.String getJPath()