public abstract class JsonSchemaTree extends BaseJsonTree
JsonTree
carrying URI resolution context information
In addition to what JsonTree
does, this tree also modifies URI
resolution context information when changing paths, and adds methods in order
to query this resolution context.
All context information is carried as JSON References, since this is what is used for addressing in JSON Schema.
JsonRef
,
CanonicalSchemaTree
,
InlineSchemaTree
Modifier and Type | Field and Description |
---|---|
protected JsonRef |
currentRef
The current resolution context
|
protected JsonRef |
loadingRef
The JSON Reference from which this node has been loaded
|
protected Deque<JsonRef> |
refStack
The stack of resolution contexts
|
protected JsonRef |
startingRef
The JSON Reference representing the context at the root of the schema
|
baseNode, currentNode, currentPointer, FACTORY, nodeStack, pointerStack
Modifier | Constructor and Description |
---|---|
protected |
JsonSchemaTree(JsonRef loadingRef,
JsonNode baseNode,
Dereferencing dereferencing)
The main constructor
|
Modifier and Type | Method and Description |
---|---|
void |
append(JsonPointer ptr)
Append a JSON Pointer to the current path
|
JsonNode |
asJson() |
abstract boolean |
containsRef(JsonRef ref)
Tell whether a JSON Reference is contained within this schema tree
|
JsonSchemaTree |
copy()
Return a copy of this tree at its current state but with an empty stack
|
boolean |
equals(Object obj) |
JsonRef |
getCurrentRef()
Get the current resolution context
|
JsonRef |
getLoadingRef()
Get the loading URI for that schema
|
int |
hashCode() |
protected static JsonRef |
idFromNode(JsonNode node)
Build a JSON Reference from a node
|
abstract JsonPointer |
matchingPointer(JsonRef ref)
Return a matching pointer in this tree for a fully resolved reference
|
void |
pop()
Reverts the last append
|
JsonRef |
resolve(JsonRef other)
Resolve a JSON Reference against the current resolution context
|
void |
setPointer(JsonPointer pointer) |
String |
toString() |
getCurrentNode, getCurrentPointer, popNode, popPointer, pushNode, pushPointer
protected final JsonRef loadingRef
If loaded without a URI, this will be the empty reference.
protected final JsonRef startingRef
It will defer from loadingRef
if there is an id
at
the top level.
protected JsonRef currentRef
protected JsonSchemaTree(JsonRef loadingRef, JsonNode baseNode, Dereferencing dereferencing)
loadingRef
- the loading referencebaseNode
- the base nodepublic final void append(JsonPointer ptr)
JsonTree
ptr
- the pointer to appendJsonPointer.append(JsonPointer)
public final void pop()
JsonTree
Note: this operation will fail badly if you haven't appended anything, so use with care!
public final void setPointer(JsonPointer pointer)
public final JsonRef resolve(JsonRef other)
other
- the JSON Reference to resolveJsonRef.resolve(JsonRef)
public abstract boolean containsRef(JsonRef ref)
This method will return true
if the caller can attempt
to retrieve the JSON value addressed by this reference from the schema
tree directly.
Note that the reference must be fully resolved for this method to work.
ref
- the target referenceresolve(JsonRef)
public abstract JsonPointer matchingPointer(JsonRef ref)
This must be called only when containsRef(JsonRef)
returns true
. Otherwise, its result is undefined.
ref
- the referencenull
if not foundpublic final JsonRef getLoadingRef()
JsonRef
public final JsonRef getCurrentRef()
JsonRef
public final JsonSchemaTree copy()
protected static JsonRef idFromNode(JsonNode node)
This will return null
if the reference could not be built. The
conditions for a successful build are as follows:
id
;node
- the nodenull
public final int hashCode()
hashCode
in class BaseJsonTree
public final boolean equals(Object obj)
equals
in class BaseJsonTree
public final JsonNode asJson()
public final String toString()
toString
in class BaseJsonTree
Copyright © 2013. All Rights Reserved.