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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final URL resourceURL
      private final J node
      private final JSONPointer pointer
      private final Resource<JSONObject> resource
      private final JSONRef<J> ref
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourceRef(Resource<JSONObject> resource, JSONRef<J> ref)
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

      • ResourceRef

        ResourceRef(Resource<JSONObject> resource, JSONRef<J> ref)
    • Method Detail

      • 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.

      • 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 ResourceRef pointing 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.