com.github.fge.jackson.jsonpointer
Class ReferenceToken

java.lang.Object
  extended by com.github.fge.jackson.jsonpointer.ReferenceToken

@Immutable
public final class ReferenceToken
extends Object

One JSON Pointer reference token

This class represents one reference token. It has no publicly available constructor; instead, it has static factory methods used to generate tokens depending on whether the input is a decoded (raw) token or an encoded (cooked) one, or even an integer.

The only characters to encode in a raw token are / (which becomes ~1) and ~ (which becomes ~0).

Note that a reference token may be empty (empty object member names are legal!).


Method Summary
 boolean equals(Object obj)
           
static ReferenceToken fromCooked(String cooked)
          Generate a reference token from an encoded (cooked) representation
static ReferenceToken fromInt(int index)
          Generate a reference token from an integer
static ReferenceToken fromRaw(String raw)
          Generate a reference token from a decoded (raw) representation
 String getRaw()
          Get the raw representation of that token as a string
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

fromCooked

public static ReferenceToken fromCooked(String cooked)
                                 throws JsonPointerException
Generate a reference token from an encoded (cooked) representation

Parameters:
cooked - the input
Returns:
a token
Throws:
JsonPointerException - illegal token (bad encode sequence)
NullPointerException - null input

fromRaw

public static ReferenceToken fromRaw(String raw)
Generate a reference token from a decoded (raw) representation

Parameters:
raw - the input
Returns:
a token
Throws:
NullPointerException - null input

fromInt

public static ReferenceToken fromInt(int index)
Generate a reference token from an integer

Parameters:
index - the integer
Returns:
a token

getRaw

public String getRaw()
Get the raw representation of that token as a string

Returns:
the raw representation (for traversing purposes)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object