Package sk.antons.json.impl
Class JsonObjectImpl
java.lang.Object
sk.antons.json.impl.JsonValueImpl
sk.antons.json.impl.JsonObjectImpl
- All Implemented Interfaces:
JsonGroup,JsonMember,JsonObject,JsonValue
- Author:
- antons
-
Field Summary
Fields inherited from class sk.antons.json.impl.JsonValueImpl
group -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds attribute ti this json object at last position.Adds attribute ti this json object at specified position.Values of all attributes with specidied nameConverts value to value usable for some template frameworks.attr(int index) Reads n'th attribute of this json objectReads first attribute of this json object with specified nameattrs()Reads all attributes of this json object with specified namevoidclear()Clears all attributes from this json object.copy()Makes deep copy of this value.voidfindFirst(PathMatcher matcher, List<String> path) first()Returns value of first attribute.Value of first attribute with specidied nameintfirstIndex(String name) Index of first attribute with specidied namebooleanisEmpty()Checks if object has any attribute.last()Returns value of last attribute.intvoidremove()Removes this instance from parent object.voidremove(JsonAttribute attr) Removes all values with specified name.removeAttr(int index) Removes n'th attribute from this json object.intsize()Size of json object.protected voidtoList()Converts attributes to regular list.protected voidtoPrettyString(Appendable sb, String prefix, String indent) Methods inherited from class sk.antons.json.impl.JsonValueImpl
asArray, asBoolLiteral, asExpLiteral, asFracLiteral, asIntLiteral, asLiteral, asNullLiteral, asObject, asStringLiteral, find, find, findAll, findAllLiterals, findFirst, findFirstLiteral, group, isArray, isBoolLiteral, isDescendantOf, isExpLiteral, isFracLiteral, isIntLiteral, isLiteral, isNullLiteral, isObject, isStringLiteral, name, parent, parentIndex, path, pathAsString, replaceBy, setGroup, toCompactString, toPrettyString, writeCompact, writePrettyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface sk.antons.json.impl.JsonGroup
isDescendantOfMethods inherited from interface sk.antons.json.impl.JsonMember
group, setGroupMethods inherited from interface sk.antons.json.JsonValue
asArray, asBoolLiteral, asExpLiteral, asFracLiteral, asIntLiteral, asLiteral, asNullLiteral, asObject, asStringLiteral, find, find, findAll, findAllLiterals, findFirst, findFirstLiteral, isArray, isBoolLiteral, isDescendantOf, isExpLiteral, isFracLiteral, isIntLiteral, isLiteral, isNullLiteral, isObject, isStringLiteral, name, parent, parentIndex, path, pathAsString, replaceBy, toCompactString, toPrettyString, writeCompact, writePretty
-
Constructor Details
-
JsonObjectImpl
public JsonObjectImpl()
-
-
Method Details
-
attrs
-
toCompactString
- Specified by:
toCompactStringin classJsonValueImpl
-
toPrettyString
- Specified by:
toPrettyStringin classJsonValueImpl
-
isEmpty
public boolean isEmpty()Description copied from interface:JsonObjectChecks if object has any attribute.- Specified by:
isEmptyin interfaceJsonObject- Returns:
- true if object has no attribute
-
size
public int size()Description copied from interface:JsonObjectSize of json object.- Specified by:
sizein interfaceJsonObject- Returns:
- number of attributes.
-
clear
public void clear()Description copied from interface:JsonObjectClears all attributes from this json object.- Specified by:
clearin interfaceJsonObject
-
attr
Description copied from interface:JsonObjectReads n'th attribute of this json object- Specified by:
attrin interfaceJsonObject- Parameters:
index- of the attribute which is read (first attribute has index=0)- Returns:
- attribute at index position
-
first
Description copied from interface:JsonObjectReturns value of first attribute.- Specified by:
firstin interfaceJsonObject- Returns:
- first attribute value or null if json object is empty
-
last
Description copied from interface:JsonObjectReturns value of last attribute.- Specified by:
lastin interfaceJsonObject- Returns:
- last attribute value or null if json object is empty
-
removeAttr
Description copied from interface:JsonObjectRemoves n'th attribute from this json object.- Specified by:
removeAttrin interfaceJsonObject- Parameters:
index- position of attribute which should be removed- Returns:
- remoced attribute
-
toList
Description copied from interface:JsonObjectConverts attributes to regular list.- Specified by:
toListin interfaceJsonObject- Returns:
-
add
Description copied from interface:JsonObjectAdds attribute ti this json object at last position.- Specified by:
addin interfaceJsonObject- Parameters:
name- name of the attributevalue- value of the attribute- Returns:
- this json object
-
add
Description copied from interface:JsonObjectAdds attribute ti this json object at specified position.- Specified by:
addin interfaceJsonObject- Parameters:
name- name of the attributevalue- value of the attributeindex- position of the attribute- Returns:
- this json object
-
firstIndex
Description copied from interface:JsonObjectIndex of first attribute with specidied name- Specified by:
firstIndexin interfaceJsonObject- Parameters:
name- name of the attribute which should be found- Returns:
- index fist attribute with the name of null if it is not found
-
first
Description copied from interface:JsonObjectValue of first attribute with specidied name- Specified by:
firstin interfaceJsonObject- Parameters:
name- name of the attribute which should be found- Returns:
- value of fist attribute with the name of null if it is not found
-
all
Description copied from interface:JsonObjectValues of all attributes with specidied name- Specified by:
allin interfaceJsonObject- Parameters:
name- name of the attributes which should be found- Returns:
- values of all attributes with the name
-
removeAll
Description copied from interface:JsonObjectRemoves all values with specified name.- Specified by:
removeAllin interfaceJsonObject- Parameters:
name- of attributes to be removed- Returns:
- this json object
-
memberIndex
- Specified by:
memberIndexin interfaceJsonGroup
-
findFirst
- Specified by:
findFirstin classJsonValueImpl
-
findAll
- Specified by:
findAllin classJsonValueImpl
-
attr
Description copied from interface:JsonObjectReads first attribute of this json object with specified name- Specified by:
attrin interfaceJsonObject- Parameters:
name- of the attribute which is read (first attribute with the name will be returned)- Returns:
- first attribute with the name
-
attrs
Description copied from interface:JsonObjectReads all attributes of this json object with specified name- Specified by:
attrsin interfaceJsonObject- Parameters:
name- of the attributes which is read (all attributes with the name will be returned)- Returns:
- all attributes with the name
-
remove
-
remove
public void remove()Description copied from interface:JsonValueRemoves this instance from parent object.- Specified by:
removein interfaceJsonValue- Overrides:
removein classJsonValueImpl
-
copy
Description copied from interface:JsonValueMakes deep copy of this value. -
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
-