Package com.networknt.schema
Class JsonNodePath
java.lang.Object
com.networknt.schema.JsonNodePath
- All Implemented Interfaces:
Comparable<JsonNodePath>
Represents a path to a JSON node.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend
(int index) Append the index to the path.Append the child token to the path.int
compareTo
(JsonNodePath other) boolean
Tests if this path contains a string segment that is an exact match.boolean
getElement
(int index) Gets the element given an index.getName
(int index) Gets the name element given an index.int
Gets the number of name elements in the path.Returns the parent path, or null if this path does not have a parent.Gets thePathType
.int
hashCode()
boolean
startsWith
(JsonNodePath other) Tests if this path starts with the other path.toString()
-
Constructor Details
-
JsonNodePath
-
-
Method Details
-
getParent
Returns the parent path, or null if this path does not have a parent.- Returns:
- the parent
-
append
Append the child token to the path.- Parameters:
token
- the child token- Returns:
- the path
-
append
Append the index to the path.- Parameters:
index
- the index- Returns:
- the path
-
getPathType
Gets thePathType
.- Returns:
- the path type
-
getName
Gets the name element given an index.The index parameter is the index of the name element to return. The element that is closest to the root has index 0. The element that is farthest from the root has index count -1.
- Parameters:
index
- to return- Returns:
- the name element
-
getElement
Gets the element given an index.The index parameter is the index of the element to return. The element that is closest to the root has index 0. The element that is farthest from the root has index count -1.
- Parameters:
index
- to return- Returns:
- the element either a String or Integer
-
getNameCount
public int getNameCount()Gets the number of name elements in the path.- Returns:
- the number of elements in the path or 0 if this is the root element
-
startsWith
Tests if this path starts with the other path.- Parameters:
other
- the other path- Returns:
- true if the path starts with the other path
-
contains
Tests if this path contains a string segment that is an exact match.This will not match if the segment is a number.
- Parameters:
segment
- the segment to test- Returns:
- true if the string segment is found
-
toString
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareTo
in interfaceComparable<JsonNodePath>
-