Package sk.antons.json.impl
Class JsonArrayImpl
- java.lang.Object
-
- sk.antons.json.impl.JsonValueImpl
-
- sk.antons.json.impl.JsonArrayImpl
-
- All Implemented Interfaces:
JsonGroup,JsonMember,JsonArray,JsonValue
public class JsonArrayImpl extends JsonValueImpl implements JsonArray, JsonGroup, JsonMember
- Author:
- antons
-
-
Field Summary
-
Fields inherited from class sk.antons.json.impl.JsonValueImpl
group
-
-
Constructor Summary
Constructors Constructor Description JsonArrayImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonArrayadd(JsonValue value)Adds new element to json array.JsonArrayadd(JsonValue value, int index)Adds new element to json array at specified position.ObjectasTemplateParam()Converts value to value usable for some template frameworks.voidclear()Clears content of json array.JsonValuecopy()Makes deep copy of this value.voidfindAll(PathMatcher matcher, List<JsonValue> values, List<String> path)JsonValuefindFirst(PathMatcher matcher, List<String> path)JsonValuefirst()Reads first element of json array.JsonValueget(int index)Reads n'th item from json array.booleanisEmpty()Checks if this json array contains no value.JsonValuelast()Reads last element of json array.intmemberIndex(JsonMember m)JsonValueremove(int index)Removes n'th element from json array.voidremove(JsonValue value)voidreplaceBy(JsonValue oldValue, JsonValue newValue)intsize()Size of json array.voidtoCompactString(StringBuilder sb)List<JsonValue>toList()Converts this instance to regulat list of values.voidtoPrettyString(StringBuilder sb, String prefix, String indent)List<JsonValue>values()-
Methods inherited from class sk.antons.json.impl.JsonValueImpl
asArray, asBoolLiteral, asExpLiteral, asFracLiteral, asIntLiteral, asLiteral, asNullLiteral, asObject, asStringLiteral, findAll, findAllLiterals, findFirst, findFirstLiteral, group, isArray, isBoolLiteral, isDescendantOf, isExpLiteral, isFracLiteral, isIntLiteral, isLiteral, isNullLiteral, isObject, isStringLiteral, name, parent, parentIndex, path, pathAsString, remove, replaceBy, setGroup, toCompactString, toPrettyString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface sk.antons.json.impl.JsonGroup
isDescendantOf
-
Methods inherited from interface sk.antons.json.impl.JsonMember
group, setGroup
-
Methods inherited from interface sk.antons.json.JsonValue
asArray, asBoolLiteral, asExpLiteral, asFracLiteral, asIntLiteral, asLiteral, asNullLiteral, asObject, asStringLiteral, findAll, findAllLiterals, findFirst, findFirstLiteral, isArray, isBoolLiteral, isDescendantOf, isExpLiteral, isFracLiteral, isIntLiteral, isLiteral, isNullLiteral, isObject, isStringLiteral, name, parent, parentIndex, path, pathAsString, remove, replaceBy, toCompactString, toPrettyString
-
-
-
-
Method Detail
-
toCompactString
public void toCompactString(StringBuilder sb)
- Specified by:
toCompactStringin classJsonValueImpl
-
toPrettyString
public void toPrettyString(StringBuilder sb, String prefix, String indent)
- Specified by:
toPrettyStringin classJsonValueImpl
-
isEmpty
public boolean isEmpty()
Description copied from interface:JsonArrayChecks if this json array contains no value.
-
size
public int size()
Description copied from interface:JsonArraySize of json array.
-
clear
public void clear()
Description copied from interface:JsonArrayClears content of json array.
-
get
public JsonValue get(int index)
Description copied from interface:JsonArrayReads n'th item from json array.
-
remove
public JsonValue remove(int index)
Description copied from interface:JsonArrayRemoves n'th element from json array.
-
first
public JsonValue first()
Description copied from interface:JsonArrayReads first element of json array.
-
last
public JsonValue last()
Description copied from interface:JsonArrayReads last element of json array.
-
add
public JsonArray add(JsonValue value)
Description copied from interface:JsonArrayAdds new element to json array.
-
add
public JsonArray add(JsonValue value, int index)
Description copied from interface:JsonArrayAdds new element to json array at specified position.
-
toList
public List<JsonValue> toList()
Description copied from interface:JsonArrayConverts this instance to regulat list of values.
-
memberIndex
public int memberIndex(JsonMember m)
- Specified by:
memberIndexin interfaceJsonGroup
-
findFirst
public JsonValue findFirst(PathMatcher matcher, List<String> path)
- Specified by:
findFirstin classJsonValueImpl
-
findAll
public void findAll(PathMatcher matcher, List<JsonValue> values, List<String> path)
- Specified by:
findAllin classJsonValueImpl
-
remove
public void remove(JsonValue value)
-
copy
public JsonValue copy()
Description copied from interface:JsonValueMakes deep copy of this value.
-
asTemplateParam
public Object asTemplateParam()
Description copied from interface:JsonValueConverts value to value usable for some template frameworks. - JsonObjects is converted to read only Map - JsonArray is converted to read only List - JsonLiteral is converted to its java value- Specified by:
asTemplateParamin interfaceJsonValue- Returns:
- template parameter form of this value
-
-