Package sk.antons.json.impl
Class JsonValueImpl
- java.lang.Object
-
- sk.antons.json.impl.JsonValueImpl
-
- All Implemented Interfaces:
JsonMember,JsonValue
- Direct Known Subclasses:
JsonArrayImpl,JsonLiteralImpl,JsonObjectImpl
public abstract class JsonValueImpl extends Object implements JsonValue, JsonMember
- Author:
- antons
-
-
Constructor Summary
Constructors Constructor Description JsonValueImpl()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description JsonArrayasArray()Cast this value instance to JsonArrayJsonBoolLiteralasBoolLiteral()Cast this value instance to JsonBoolLiteralJsonExpLiteralasExpLiteral()Cast this value instance to JsonExpLiteralImplJsonFracLiteralasFracLiteral()Cast this value instance to JsonFracLiteralJsonIntLiteralasIntLiteral()Cast this value instance to JsonIntLiteralJsonLiteralasLiteral()Cast this value instance to JsonLiteralJsonNullLiteralasNullLiteral()Cast this value instance to JsonNullLiteralJsonObjectasObject()Cast this value instance to JsonObjectJsonStringLiteralasStringLiteral()Cast this value instance to JsonStringLiteralList<JsonValue>findAll(PathMatcher matcher)Find all json values with defined pathabstract voidfindAll(PathMatcher matcher, List<JsonValue> values, List<String> path)List<String>findAllLiterals(PathMatcher matcher)Find all json value with defined path and converts them to string valueJsonValuefindFirst(PathMatcher matcher)Find first json value with defined pathabstract JsonValuefindFirst(PathMatcher matcher, List<String> path)StringfindFirstLiteral(PathMatcher matcher)Find first json value with defined path and converts it to string valueJsonGroupgroup()booleanisArray()Checks if this value is instance of JsonArraybooleanisBoolLiteral()Checks if this value is instance of JsonBoolLiteralbooleanisDescendantOf(JsonValue parent)Returns true is this value is descendant of parent value;booleanisExpLiteral()Checks if this value is instance of JsonExpLiteralbooleanisFracLiteral()Checks if this value is instance of JsonFracLiteralbooleanisIntLiteral()Checks if this value is instance of JsonIntLiteralbooleanisLiteral()Checks if this value is instance of JsonLiteralbooleanisNullLiteral()Checks if this value is instance of JsonNullLiteralbooleanisObject()Checks if this value is instance of JsonObjectbooleanisStringLiteral()Checks if this value is instance of JsonStringLiteralStringname()Returns name of the instance derived from parent.JsonValueparent()Parent of this value in json structureintparentIndex()Index of this instance in parent objectString[]path()Returns path of this value in json structureStringpathAsString()Returns path of this value in json structurevoidremove()Removes this instance from parent object.voidreplaceBy(JsonValue newValue)Replaces this instance in parent object by this value.voidsetGroup(JsonGroup group)StringtoCompactString()Produces compact string representation of this json value.abstract voidtoCompactString(StringBuilder sb)StringtoPrettyString(String indent)Produces pretty (readable) string representation of this json value.abstract voidtoPrettyString(StringBuilder sb, String prefix, String indent)-
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.JsonValue
asTemplateParam, copy
-
-
-
-
Field Detail
-
group
protected JsonGroup group
-
-
Method Detail
-
group
public JsonGroup group()
- Specified by:
groupin interfaceJsonMember
-
setGroup
public void setGroup(JsonGroup group)
- Specified by:
setGroupin interfaceJsonMember
-
asObject
public JsonObject asObject()
Description copied from interface:JsonValueCast this value instance to JsonObject
-
asArray
public JsonArray asArray()
Description copied from interface:JsonValueCast this value instance to JsonArray
-
asNullLiteral
public JsonNullLiteral asNullLiteral()
Description copied from interface:JsonValueCast this value instance to JsonNullLiteral- Specified by:
asNullLiteralin interfaceJsonValue- Returns:
- this value instance bud narrow casted to JsonNullLiteral.
-
asBoolLiteral
public JsonBoolLiteral asBoolLiteral()
Description copied from interface:JsonValueCast this value instance to JsonBoolLiteral- Specified by:
asBoolLiteralin interfaceJsonValue- Returns:
- this value instance bud narrow casted to JsonBoolLiteral.
-
asExpLiteral
public JsonExpLiteral asExpLiteral()
Description copied from interface:JsonValueCast this value instance to JsonExpLiteralImpl- Specified by:
asExpLiteralin interfaceJsonValue- Returns:
- this value instance bud narrow casted to JsonExpLiteral.
-
asFracLiteral
public JsonFracLiteral asFracLiteral()
Description copied from interface:JsonValueCast this value instance to JsonFracLiteral- Specified by:
asFracLiteralin interfaceJsonValue- Returns:
- this value instance bud narrow casted to JsonFracLiteral.
-
asIntLiteral
public JsonIntLiteral asIntLiteral()
Description copied from interface:JsonValueCast this value instance to JsonIntLiteral- Specified by:
asIntLiteralin interfaceJsonValue- Returns:
- this value instance bud narrow casted to JsonIntLiteral.
-
asStringLiteral
public JsonStringLiteral asStringLiteral()
Description copied from interface:JsonValueCast this value instance to JsonStringLiteral- Specified by:
asStringLiteralin interfaceJsonValue- Returns:
- this value instance bud narrow casted to JsonStringLiteral.
-
asLiteral
public JsonLiteral asLiteral()
Description copied from interface:JsonValueCast this value instance to JsonLiteral
-
isObject
public boolean isObject()
Description copied from interface:JsonValueChecks if this value is instance of JsonObject
-
isArray
public boolean isArray()
Description copied from interface:JsonValueChecks if this value is instance of JsonArray
-
isNullLiteral
public boolean isNullLiteral()
Description copied from interface:JsonValueChecks if this value is instance of JsonNullLiteral- Specified by:
isNullLiteralin interfaceJsonValue- Returns:
- result of the check
-
isBoolLiteral
public boolean isBoolLiteral()
Description copied from interface:JsonValueChecks if this value is instance of JsonBoolLiteral- Specified by:
isBoolLiteralin interfaceJsonValue- Returns:
- result of the check
-
isExpLiteral
public boolean isExpLiteral()
Description copied from interface:JsonValueChecks if this value is instance of JsonExpLiteral- Specified by:
isExpLiteralin interfaceJsonValue- Returns:
- result of the check
-
isFracLiteral
public boolean isFracLiteral()
Description copied from interface:JsonValueChecks if this value is instance of JsonFracLiteral- Specified by:
isFracLiteralin interfaceJsonValue- Returns:
- result of the check
-
isIntLiteral
public boolean isIntLiteral()
Description copied from interface:JsonValueChecks if this value is instance of JsonIntLiteral- Specified by:
isIntLiteralin interfaceJsonValue- Returns:
- result of the check
-
isStringLiteral
public boolean isStringLiteral()
Description copied from interface:JsonValueChecks if this value is instance of JsonStringLiteral- Specified by:
isStringLiteralin interfaceJsonValue- Returns:
- result of the check
-
isLiteral
public boolean isLiteral()
Description copied from interface:JsonValueChecks if this value is instance of JsonLiteral
-
toCompactString
public String toCompactString()
Description copied from interface:JsonValueProduces compact string representation of this json value.- Specified by:
toCompactStringin interfaceJsonValue- Returns:
- compact string value
-
toPrettyString
public String toPrettyString(String indent)
Description copied from interface:JsonValueProduces pretty (readable) string representation of this json value.- Specified by:
toPrettyStringin interfaceJsonValue- Parameters:
indent- string used for indend nested levels. (ussually tab or some spaces)- Returns:
- pretty string value
-
toCompactString
public abstract void toCompactString(StringBuilder sb)
-
toPrettyString
public abstract void toPrettyString(StringBuilder sb, String prefix, String indent)
-
findAll
public List<JsonValue> findAll(PathMatcher matcher)
Description copied from interface:JsonValueFind all json values with defined path
-
findFirst
public JsonValue findFirst(PathMatcher matcher)
Description copied from interface:JsonValueFind first json value with defined path
-
findAllLiterals
public List<String> findAllLiterals(PathMatcher matcher)
Description copied from interface:JsonValueFind all json value with defined path and converts them to string value- Specified by:
findAllLiteralsin interfaceJsonValue- Parameters:
matcher- Matcher to used for identifying returned values.- Returns:
- all json value defined by path converted to string
-
findFirstLiteral
public String findFirstLiteral(PathMatcher matcher)
Description copied from interface:JsonValueFind first json value with defined path and converts it to string value- Specified by:
findFirstLiteralin interfaceJsonValue- Parameters:
matcher- Matcher to used for identifying returned value.- Returns:
- first json value defined by path converted to string
-
findFirst
public abstract JsonValue findFirst(PathMatcher matcher, List<String> path)
-
findAll
public abstract void findAll(PathMatcher matcher, List<JsonValue> values, List<String> path)
-
parent
public JsonValue parent()
Description copied from interface:JsonValueParent of this value in json structure
-
parentIndex
public int parentIndex()
Description copied from interface:JsonValueIndex of this instance in parent object- Specified by:
parentIndexin interfaceJsonValue- Returns:
- index of this instance in parent object or -1 if this is root
-
path
public String[] path()
Description copied from interface:JsonValueReturns path of this value in json structure
-
pathAsString
public String pathAsString()
Description copied from interface:JsonValueReturns path of this value in json structure- Specified by:
pathAsStringin interfaceJsonValue- Returns:
- path of this instance
-
isDescendantOf
public boolean isDescendantOf(JsonValue parent)
Description copied from interface:JsonValueReturns true is this value is descendant of parent value;- Specified by:
isDescendantOfin interfaceJsonValue- Parameters:
parent- possible paretn value- Returns:
- true if parent is parent of this.
-
remove
public void remove()
Description copied from interface:JsonValueRemoves this instance from parent object.
-
replaceBy
public void replaceBy(JsonValue newValue)
Description copied from interface:JsonValueReplaces this instance in parent object by this value. Do nothing if this object is root and works like remove() is new value is null;
-
-