Class JsonPointer

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static JsonPointer ROOT
      A JSON pointer representing the root node of a JSON document
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonPointer​(List<io.fabric8.zjsonpatch.JsonPointer.RefToken> tokens)
      Constructs a new pointer from a list of reference tokens.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      List<io.fabric8.zjsonpatch.JsonPointer.RefToken> decompose()
      Decomposes this JSON pointer into its reference tokens.
      boolean equals​(Object o)  
      com.fasterxml.jackson.databind.JsonNode evaluate​(com.fasterxml.jackson.databind.JsonNode document)
      Takes a target document and resolves the node represented by this instance.
      io.fabric8.zjsonpatch.JsonPointer.RefToken get​(int index)
      Retrieves the reference token at the specified index.
      JsonPointer getParent()
      Creates a JSON pointer to the parent of the node represented by this instance.
      int hashCode()  
      boolean isRoot()
      Indicates whether or not this instance points to the root of a JSON document.
      io.fabric8.zjsonpatch.JsonPointer.RefToken last()
      Retrieves the last reference token for this JSON pointer.
      static JsonPointer parse​(String path)
      Parses a valid string representation of a JSON Pointer.
      String toString()
      Returns a string representation of this instance
    • Field Detail

      • ROOT

        public static final JsonPointer ROOT
        A JSON pointer representing the root node of a JSON document
    • Constructor Detail

      • JsonPointer

        public JsonPointer​(List<io.fabric8.zjsonpatch.JsonPointer.RefToken> tokens)
        Constructs a new pointer from a list of reference tokens.
        Parameters:
        tokens - The list of reference tokens from which to construct the new pointer. This list is not modified.
    • Method Detail

      • isRoot

        public boolean isRoot()
        Indicates whether or not this instance points to the root of a JSON document.
        Returns:
        true if this pointer represents the root node, false otherwise.
      • toString

        public String toString()
        Returns a string representation of this instance
        Overrides:
        toString in class Object
        Returns:
        An RFC 6901 compliant string representation of this JSON pointer.
      • decompose

        public List<io.fabric8.zjsonpatch.JsonPointer.RefToken> decompose()
        Decomposes this JSON pointer into its reference tokens.
        Returns:
        A list of JsonPointer.RefTokens. Modifications to this list do not affect this instance.
      • get

        public io.fabric8.zjsonpatch.JsonPointer.RefToken get​(int index)
                                                       throws IndexOutOfBoundsException
        Retrieves the reference token at the specified index.
        Parameters:
        index - The desired reference token index.
        Returns:
        The specified instance of JsonPointer.RefToken.
        Throws:
        IndexOutOfBoundsException - The specified index is illegal.
      • last

        public io.fabric8.zjsonpatch.JsonPointer.RefToken last()
        Retrieves the last reference token for this JSON pointer.
        Returns:
        The last JsonPointer.RefToken comprising this instance.
        Throws:
        IllegalStateException - Last cannot be called on root pointers.
      • getParent

        public JsonPointer getParent()
        Creates a JSON pointer to the parent of the node represented by this instance. The parent of the root pointer is the root pointer itself.
        Returns:
        A JsonPointer to the parent node.
      • evaluate

        public com.fasterxml.jackson.databind.JsonNode evaluate​(com.fasterxml.jackson.databind.JsonNode document)
                                                         throws JsonPointerEvaluationException
        Takes a target document and resolves the node represented by this instance. The evaluation semantics are described in RFC 6901 sectino 4.
        Parameters:
        document - The target document against which to evaluate the JSON pointer.
        Returns:
        The JsonNode resolved by evaluating this JSON pointer.
        Throws:
        JsonPointerEvaluationException - The pointer could not be evaluated.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object