Class JsonValueImpl

    • Constructor Detail

      • JsonValueImpl

        public JsonValueImpl()
    • Method Detail

      • asObject

        public JsonObject asObject()
        Description copied from interface: JsonValue
        Cast this value instance to JsonObject
        Specified by:
        asObject in interface JsonValue
        Returns:
        this value instance bud narrow casted to JsonObject.
      • asArray

        public JsonArray asArray()
        Description copied from interface: JsonValue
        Cast this value instance to JsonArray
        Specified by:
        asArray in interface JsonValue
        Returns:
        this value instance bud narrow casted to JsonArray.
      • asNullLiteral

        public JsonNullLiteral asNullLiteral()
        Description copied from interface: JsonValue
        Cast this value instance to JsonNullLiteral
        Specified by:
        asNullLiteral in interface JsonValue
        Returns:
        this value instance bud narrow casted to JsonNullLiteral.
      • asBoolLiteral

        public JsonBoolLiteral asBoolLiteral()
        Description copied from interface: JsonValue
        Cast this value instance to JsonBoolLiteral
        Specified by:
        asBoolLiteral in interface JsonValue
        Returns:
        this value instance bud narrow casted to JsonBoolLiteral.
      • asExpLiteral

        public JsonExpLiteral asExpLiteral()
        Description copied from interface: JsonValue
        Cast this value instance to JsonExpLiteralImpl
        Specified by:
        asExpLiteral in interface JsonValue
        Returns:
        this value instance bud narrow casted to JsonExpLiteral.
      • asFracLiteral

        public JsonFracLiteral asFracLiteral()
        Description copied from interface: JsonValue
        Cast this value instance to JsonFracLiteral
        Specified by:
        asFracLiteral in interface JsonValue
        Returns:
        this value instance bud narrow casted to JsonFracLiteral.
      • asIntLiteral

        public JsonIntLiteral asIntLiteral()
        Description copied from interface: JsonValue
        Cast this value instance to JsonIntLiteral
        Specified by:
        asIntLiteral in interface JsonValue
        Returns:
        this value instance bud narrow casted to JsonIntLiteral.
      • asStringLiteral

        public JsonStringLiteral asStringLiteral()
        Description copied from interface: JsonValue
        Cast this value instance to JsonStringLiteral
        Specified by:
        asStringLiteral in interface JsonValue
        Returns:
        this value instance bud narrow casted to JsonStringLiteral.
      • asLiteral

        public JsonLiteral asLiteral()
        Description copied from interface: JsonValue
        Cast this value instance to JsonLiteral
        Specified by:
        asLiteral in interface JsonValue
        Returns:
        this value instance bud narrow casted to JsonLiteral.
      • isObject

        public boolean isObject()
        Description copied from interface: JsonValue
        Checks if this value is instance of JsonObject
        Specified by:
        isObject in interface JsonValue
        Returns:
        result of the check
      • isArray

        public boolean isArray()
        Description copied from interface: JsonValue
        Checks if this value is instance of JsonArray
        Specified by:
        isArray in interface JsonValue
        Returns:
        result of the check
      • isNullLiteral

        public boolean isNullLiteral()
        Description copied from interface: JsonValue
        Checks if this value is instance of JsonNullLiteral
        Specified by:
        isNullLiteral in interface JsonValue
        Returns:
        result of the check
      • isBoolLiteral

        public boolean isBoolLiteral()
        Description copied from interface: JsonValue
        Checks if this value is instance of JsonBoolLiteral
        Specified by:
        isBoolLiteral in interface JsonValue
        Returns:
        result of the check
      • isExpLiteral

        public boolean isExpLiteral()
        Description copied from interface: JsonValue
        Checks if this value is instance of JsonExpLiteral
        Specified by:
        isExpLiteral in interface JsonValue
        Returns:
        result of the check
      • isFracLiteral

        public boolean isFracLiteral()
        Description copied from interface: JsonValue
        Checks if this value is instance of JsonFracLiteral
        Specified by:
        isFracLiteral in interface JsonValue
        Returns:
        result of the check
      • isIntLiteral

        public boolean isIntLiteral()
        Description copied from interface: JsonValue
        Checks if this value is instance of JsonIntLiteral
        Specified by:
        isIntLiteral in interface JsonValue
        Returns:
        result of the check
      • isStringLiteral

        public boolean isStringLiteral()
        Description copied from interface: JsonValue
        Checks if this value is instance of JsonStringLiteral
        Specified by:
        isStringLiteral in interface JsonValue
        Returns:
        result of the check
      • isLiteral

        public boolean isLiteral()
        Description copied from interface: JsonValue
        Checks if this value is instance of JsonLiteral
        Specified by:
        isLiteral in interface JsonValue
        Returns:
        result of the check
      • toCompactString

        public String toCompactString()
        Description copied from interface: JsonValue
        Produces compact string representation of this json value.
        Specified by:
        toCompactString in interface JsonValue
        Returns:
        compact string value
      • toPrettyString

        public String toPrettyString​(String indent)
        Description copied from interface: JsonValue
        Produces pretty (readable) string representation of this json value.
        Specified by:
        toPrettyString in interface JsonValue
        Parameters:
        indent - string used for indend nested levels. (ussually tab or some spaces)
        Returns:
        pretty string value
      • toCompactString

        public abstract void toCompactString​(StringBuilder sb)
      • findAll

        public List<JsonValue> findAll​(PathMatcher matcher)
        Description copied from interface: JsonValue
        Find all json values with defined path
        Specified by:
        findAll in interface JsonValue
        Parameters:
        matcher - Matcher to used for identifying returned values.
        Returns:
        all json values defined by path
      • findFirst

        public JsonValue findFirst​(PathMatcher matcher)
        Description copied from interface: JsonValue
        Find first json value with defined path
        Specified by:
        findFirst in interface JsonValue
        Parameters:
        matcher - Matcher to used for identifying returned value.
        Returns:
        first json value defined by path
      • findAllLiterals

        public List<String> findAllLiterals​(PathMatcher matcher)
        Description copied from interface: JsonValue
        Find all json value with defined path and converts them to string value
        Specified by:
        findAllLiterals in interface JsonValue
        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: JsonValue
        Find first json value with defined path and converts it to string value
        Specified by:
        findFirstLiteral in interface JsonValue
        Parameters:
        matcher - Matcher to used for identifying returned value.
        Returns:
        first json value defined by path converted to string
      • parent

        public JsonValue parent()
        Description copied from interface: JsonValue
        Parent of this value in json structure
        Specified by:
        parent in interface JsonValue
        Returns:
        parent json value or null if this instance is root
      • parentIndex

        public int parentIndex()
        Description copied from interface: JsonValue
        Index of this instance in parent object
        Specified by:
        parentIndex in interface JsonValue
        Returns:
        index of this instance in parent object or -1 if this is root
      • path

        public String[] path()
        Description copied from interface: JsonValue
        Returns path of this value in json structure
        Specified by:
        path in interface JsonValue
        Returns:
        path of this instance
      • pathAsString

        public String pathAsString()
        Description copied from interface: JsonValue
        Returns path of this value in json structure
        Specified by:
        pathAsString in interface JsonValue
        Returns:
        path of this instance
      • isDescendantOf

        public boolean isDescendantOf​(JsonValue parent)
        Description copied from interface: JsonValue
        Returns true is this value is descendant of parent value;
        Specified by:
        isDescendantOf in interface JsonValue
        Parameters:
        parent - possible paretn value
        Returns:
        true if parent is parent of this.
      • remove

        public void remove()
        Description copied from interface: JsonValue
        Removes this instance from parent object.
        Specified by:
        remove in interface JsonValue
      • replaceBy

        public void replaceBy​(JsonValue newValue)
        Description copied from interface: JsonValue
        Replaces this instance in parent object by this value. Do nothing if this object is root and works like remove() is new value is null;
        Specified by:
        replaceBy in interface JsonValue
        Parameters:
        newValue - new value which must replace this instance.
      • name

        public String name()
        Description copied from interface: JsonValue
        Returns name of the instance derived from parent.
        Specified by:
        name in interface JsonValue
        Returns:
        name of value in json tree or null if it is root.