com.github.fge.jackson.jsonpointer
Class JsonPointer

java.lang.Object
  extended by com.github.fge.jackson.jsonpointer.TreePointer<JsonNode>
      extended by com.github.fge.jackson.jsonpointer.JsonPointer
All Implemented Interfaces:
Iterable<TokenResolver<JsonNode>>

@Immutable
public final class JsonPointer
extends TreePointer<JsonNode>

A TreePointer for JsonNode

This is the "original" JSON Pointer in that it addresses JSON documents.

It also has a lot of utility methods covering several usage scenarios.


Field Summary
 
Fields inherited from class com.github.fge.jackson.jsonpointer.TreePointer
BUNDLE, tokenResolvers
 
Constructor Summary
JsonPointer(List<TokenResolver<JsonNode>> tokenResolvers)
          Alternate constructor
JsonPointer(String input)
          The main constructor
 
Method Summary
 JsonPointer append(int index)
          Return a new pointer with a new integer token appended
 JsonPointer append(JsonPointer other)
          Return a new pointer with another pointer appended
 JsonPointer append(String raw)
          Return a new pointer with a new token appended
static JsonPointer empty()
          Return an empty JSON Pointer
static JsonPointer of(Object first, Object... other)
          Build a JSON Pointer out of a series of reference tokens
 JsonPointer parent()
          Return the immediate parent of this JSON Pointer
 
Methods inherited from class com.github.fge.jackson.jsonpointer.TreePointer
equals, get, hashCode, isEmpty, iterator, path, tokensFromInput, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JsonPointer

public JsonPointer(String input)
            throws JsonPointerException
The main constructor

Parameters:
input - the input string
Throws:
JsonPointerException - malformed JSON Pointer
NullPointerException - null input

JsonPointer

public JsonPointer(List<TokenResolver<JsonNode>> tokenResolvers)
Alternate constructor

This calls TreePointer.TreePointer(TreeNode, List) with a MissingNode as the missing tree node.

Parameters:
tokenResolvers - the list of token resolvers
Method Detail

empty

public static JsonPointer empty()
Return an empty JSON Pointer

Returns:
an empty, statically allocated JSON Pointer

of

public static JsonPointer of(Object first,
                             Object... other)
Build a JSON Pointer out of a series of reference tokens

These tokens can be everything; be sure however that they implement Object.toString() correctly!

Each of these tokens are treated as raw tokens (ie, not encoded).

Parameters:
first - the first token
other - other tokens
Returns:
a JSON Pointer
Throws:
NullPointerException - one input token is null

append

public JsonPointer append(String raw)
Return a new pointer with a new token appended

Parameters:
raw - the raw token to append
Returns:
a new pointer
Throws:
NullPointerException - input is null

append

public JsonPointer append(int index)
Return a new pointer with a new integer token appended

Parameters:
index - the integer token to append
Returns:
a new pointer

append

public JsonPointer append(JsonPointer other)
Return a new pointer with another pointer appended

Parameters:
other - the other pointer
Returns:
a new pointer
Throws:
NullPointerException - other pointer is null

parent

public JsonPointer parent()
Return the immediate parent of this JSON Pointer

The parent of the empty pointer is itself.

Returns:
a new JSON Pointer representing the parent of the current one