public static final class JSONWriter.Path
extends java.lang.Object
The Path class is used internally by JSONWriter to manage object references and generate JSON Pointer strings as defined in RFC 6901. Paths are hierarchical, with each Path instance containing a reference to its parent Path, forming a tree structure that mirrors the JSON structure being serialized.
Path instances are immutable once created and are used in reference detection to determine if an object has already been serialized at another location in the JSON structure.
Example paths:
| Modifier and Type | Field and Description |
|---|---|
(package private) JSONWriter.Path |
child0
First child path cache for optimization.
|
(package private) JSONWriter.Path |
child1
Second child path cache for optimization.
|
(package private) java.lang.String |
fullPath
The cached full path string representation, computed lazily.
|
(package private) int |
index
The array index of this path segment, or -1 if this represents a property name.
|
static JSONWriter.Path |
MANGER_REFERNCE
The manager reference path instance, used for special reference handling.
|
(package private) java.lang.String |
name
The name of this path segment, or null if this represents an array index.
|
JSONWriter.Path |
parent
The parent path of this path segment, or null if this is the root path.
|
static JSONWriter.Path |
ROOT
The root path instance, representing the top level of the JSON structure.
|
| Constructor and Description |
|---|
Path(JSONWriter.Path parent,
int index)
Creates a new Path instance representing an array index.
|
Path(JSONWriter.Path parent,
java.lang.String name)
Creates a new Path instance representing a named property.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o)
Compares this Path with another object for equality.
|
int |
hashCode()
Returns a hash code value for this Path.
|
java.lang.String |
toString()
Returns a string representation of this Path in JSON Pointer format.
|
public static final JSONWriter.Path ROOT
public static final JSONWriter.Path MANGER_REFERNCE
public final JSONWriter.Path parent
final java.lang.String name
final int index
java.lang.String fullPath
JSONWriter.Path child0
JSONWriter.Path child1
public Path(JSONWriter.Path parent, java.lang.String name)
parent - the parent path, or null for the root pathname - the property name for this path segmentpublic Path(JSONWriter.Path parent, int index)
parent - the parent path, or null for the root pathindex - the array index for this path segmentpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the object to compare withpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object