Package com.networknt.schema
Class JsonNodePath
- java.lang.Object
-
- com.networknt.schema.JsonNodePath
-
- All Implemented Interfaces:
Comparable<JsonNodePath>
public class JsonNodePath extends Object implements Comparable<JsonNodePath>
Represents a path to a JSON node.
-
-
Constructor Summary
Constructors Constructor Description JsonNodePath(PathType type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonNodePathappend(int index)Append the index to the path.JsonNodePathappend(String token)Append the child token to the path.intcompareTo(JsonNodePath other)booleanequals(Object obj)ObjectgetElement(int index)Gets the element given an index.StringgetName(int index)Gets the name element given an index.intgetNameCount()Gets the number of name elements in the path.JsonNodePathgetParent()Returns the parent path, or null if this path does not have a parent.PathTypegetPathType()Gets thePathType.inthashCode()booleanstartsWith(JsonNodePath other)Tests if this path starts with the other path.StringtoString()
-
-
-
Constructor Detail
-
JsonNodePath
public JsonNodePath(PathType type)
-
-
Method Detail
-
getParent
public JsonNodePath getParent()
Returns the parent path, or null if this path does not have a parent.- Returns:
- the parent
-
append
public JsonNodePath append(String token)
Append the child token to the path.- Parameters:
token- the child token- Returns:
- the path
-
append
public JsonNodePath append(int index)
Append the index to the path.- Parameters:
index- the index- Returns:
- the path
-
getName
public String getName(int index)
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
public Object getElement(int index)
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
public boolean startsWith(JsonNodePath other)
Tests if this path starts with the other path.- Parameters:
other- the other path- Returns:
- true if the path starts with the other path
-
compareTo
public int compareTo(JsonNodePath other)
- Specified by:
compareToin interfaceComparable<JsonNodePath>
-
-