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
- Author:
- antons
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasArray()Cast this value instance to JsonArrayCast this value instance to JsonBoolLiteralCast this value instance to JsonExpLiteralImplCast this value instance to JsonFracLiteralCast this value instance to JsonIntLiteralCast this value instance to JsonLiteralCast this value instance to JsonNullLiteralasObject()Cast this value instance to JsonObjectCast this value instance to JsonStringLiteralFinder for specified path.find(PathMatcher matcher) Finder for specified matcher.findAll(PathMatcher matcher) Find all json values with defined pathabstract voidfindAllLiterals(PathMatcher matcher) Find all json value with defined path and converts them to string valuefindFirst(PathMatcher matcher) Find first json value with defined pathabstract JsonValuefindFirst(PathMatcher matcher, List<String> path) findFirstLiteral(PathMatcher matcher) Find first json value with defined path and converts it to string valuegroup()booleanisArray()Checks if this value is instance of JsonArraybooleanChecks if this value is instance of JsonBoolLiteralbooleanisDescendantOf(JsonValue parent) Returns true is this value is descendant of parent value;booleanChecks if this value is instance of JsonExpLiteralbooleanChecks if this value is instance of JsonFracLiteralbooleanChecks if this value is instance of JsonIntLiteralbooleanChecks if this value is instance of JsonLiteralbooleanChecks if this value is instance of JsonNullLiteralbooleanisObject()Checks if this value is instance of JsonObjectbooleanChecks if this value is instance of JsonStringLiteralname()Returns name of the instance derived from parent.parent()Parent of this value in json structureintIndex of this instance in parent objectString[]path()Returns path of this value in json structureReturns path of this value in json structurevoidremove()Removes this instance from parent object.voidReplaces this instance in parent object by this value.voidProduces compact string representation of this json value.protected abstract voidprotected abstract voidtoPrettyString(Appendable sb, String prefix, String indent) toPrettyString(String indent) Produces pretty (readable) string representation of this json value.voidwriteCompact(Appendable appendable) Produces compact string representation of this json value.voidwritePretty(Appendable appendable, String indent) Produces pretty (readable) string representation of this json value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface sk.antons.json.JsonValue
asTemplateParam, copy
-
Field Details
-
group
-
-
Constructor Details
-
JsonValueImpl
public JsonValueImpl()
-
-
Method Details
-
group
- Specified by:
groupin interfaceJsonMember
-
setGroup
- Specified by:
setGroupin interfaceJsonMember
-
asObject
Description copied from interface:JsonValueCast this value instance to JsonObject -
asArray
Description copied from interface:JsonValueCast this value instance to JsonArray -
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
Description copied from interface:JsonValueCast this value instance to JsonBoolLiteral- Specified by:
asBoolLiteralin interfaceJsonValue- Returns:
- this value instance bud narrow casted to JsonBoolLiteral.
-
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
Description copied from interface:JsonValueCast this value instance to JsonFracLiteral- Specified by:
asFracLiteralin interfaceJsonValue- Returns:
- this value instance bud narrow casted to JsonFracLiteral.
-
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
Description copied from interface:JsonValueCast this value instance to JsonStringLiteral- Specified by:
asStringLiteralin interfaceJsonValue- Returns:
- this value instance bud narrow casted to JsonStringLiteral.
-
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
Description copied from interface:JsonValueProduces compact string representation of this json value.- Specified by:
toCompactStringin interfaceJsonValue- Returns:
- compact string value
-
toPrettyString
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
-
writeCompact
Description copied from interface:JsonValueProduces compact string representation of this json value.- Specified by:
writeCompactin interfaceJsonValue- Parameters:
appendable- place where json string will be written.
-
writePretty
Description copied from interface:JsonValueProduces pretty (readable) string representation of this json value.- Specified by:
writePrettyin interfaceJsonValue- Parameters:
appendable- place where json string will be written.indent- string used for indend nested levels. (ussually tab or some spaces)
-
toCompactString
-
toPrettyString
-
findAll
Description copied from interface:JsonValueFind all json values with defined path -
findFirst
Description copied from interface:JsonValueFind first json value with defined path -
findAllLiterals
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
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
-
findAll
-
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
Description copied from interface:JsonValueReturns path of this value in json structure -
pathAsString
Description copied from interface:JsonValueReturns path of this value in json structure- Specified by:
pathAsStringin interfaceJsonValue- Returns:
- path of this instance
-
isDescendantOf
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
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; -
name
Description copied from interface:JsonValueReturns name of the instance derived from parent. -
find
Description copied from interface:JsonValueFinder for specified matcher. -
find
Description copied from interface:JsonValueFinder for specified path. (SimplePathMather is used)
-