Class ResourceRef
-
- All Implemented Interfaces:
public final class ResourceRef<J extends JSONValue>A Resource Reference, combining a Resource (as described by a URL) and a JSONRef pointing to a specific location within the Resource.
-
-
Constructor Summary
Constructors Constructor Description ResourceRef(Resource<JSONObject> resource, JSONRef<J> ref)
-
Method Summary
Modifier and Type Method Description final URLgetResourceURL()final JgetNode()final JSONPointergetPointer()final Resource<JSONObject>getResource()final JSONRef<J>getRef()final <T extends JSONStructure<?>> ResourceRef<T>parent()final <T extends JSONStructure<?>> ResourceRef<T>parent(Function1<JSONValue, T> checkType)final <T extends JSONValue> ResourceRef<T>createTypedChildRef(String token, JSONValue targetNode)Create a child reference, checking the type of the target node. final <T extends JSONValue> ResourceRef<T>createChildRef(String token, T targetNode)Create a child reference. final <T extends JSONValue> ResourceRef<T>asRef(String nodeName)"Downcast" a reference to a particular type, or throw an exception if the target is not of that type. final <T extends JSONValue> BooleanisRef()Test whether reference refers to a nominated type. final ResourceRef<JSONObject>resolve(String relativeRef)Resolve a relative reference in the form "resource#node", as is commonly used in references in (for example) JSON Schema files. Booleanequals(Object other)IntegerhashCode()StringtoString()-
-
Constructor Detail
-
ResourceRef
ResourceRef(Resource<JSONObject> resource, JSONRef<J> ref)
-
-
Method Detail
-
getResourceURL
final URL getResourceURL()
-
getPointer
final JSONPointer getPointer()
-
getResource
final Resource<JSONObject> getResource()
-
parent
final <T extends JSONStructure<?>> ResourceRef<T> parent()
-
parent
final <T extends JSONStructure<?>> ResourceRef<T> parent(Function1<JSONValue, T> checkType)
-
createTypedChildRef
final <T extends JSONValue> ResourceRef<T> createTypedChildRef(String token, JSONValue targetNode)
Create a child reference, checking the type of the target node.
-
createChildRef
final <T extends JSONValue> ResourceRef<T> createChildRef(String token, T targetNode)
Create a child reference.
-
asRef
final <T extends JSONValue> ResourceRef<T> asRef(String nodeName)
"Downcast" a reference to a particular type, or throw an exception if the target is not of that type.
-
isRef
final <T extends JSONValue> Boolean isRef()
Test whether reference refers to a nominated type.
-
resolve
final ResourceRef<JSONObject> resolve(String relativeRef)
Resolve a relative reference in the form "resource#node", as is commonly used in references in (for example) JSON Schema files. The relative reference may include a resource reference to be resolved as specified by RFC-3986, followed by an optional "
#" sign and "fragment" identifier.There are, in effect, three cases:
A relative URI with no fragment; in this case the function will attempt to locate the resource identified by the relative URI, and return a
ResourceRefpointing to the root of the object.A relative URI with a fragment; the function will attempt to locate the resource as above, and will then set the pointer within the resource to the node identified by the fragment.
A fragment (with preceding "
#" sign) only; the function will set the pointer to the node identified by the fragment in the current resource.
-
-
-
-