public final class JsonRef extends Object
JSON Reference, currently a draft, is a way to address a JSON instance of whatever type.
To quote the draft, "A JSON Reference is a JSON object, which contains a member named "$ref", which has a JSON string value." This string value must be a URI. Example:
{
"$ref": "http://example.com/example.json#/foo/bar"
}
Here we choose to derive a little from the specification and calculate
references from any field, not just $ref. This class is also used,
for instance, to compute id.
The implementation is a wrapper over Java's URI,
with the following differences:
| Modifier and Type | Field and Description |
|---|---|
private static LoadingCache<URI,JsonRef> |
cache |
private static JsonRef |
EMPTY |
private static URI |
EMPTY_URI |
private JsonFragment |
fragment |
private static URI |
HASHONLY_URI |
private URI |
locator |
private URI |
uri
The URI, as provided by the input arguments
|
| Modifier | Constructor and Description |
|---|---|
private |
JsonRef(URI uri)
The main constructor, which is private by design
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(JsonRef other) |
static JsonRef |
emptyRef() |
boolean |
equals(Object obj) |
static JsonRef |
fromString(String s) |
static JsonRef |
fromURI(URI uri) |
JsonFragment |
getFragment()
Return this ref's fragment part as a string
|
URI |
getRootAsURI()
Return the absolute part of the underlying URI, without the fragment
|
int |
hashCode() |
boolean |
isAbsolute() |
boolean |
isEmpty() |
JsonRef |
resolve(JsonRef other) |
String |
toString() |
private static final URI HASHONLY_URI
private static final URI EMPTY_URI
private static final JsonRef EMPTY
private static final LoadingCache<URI,JsonRef> cache
private final URI uri
private final URI locator
private final JsonFragment fragment
private JsonRef(URI uri)
uri - Input URIpublic static JsonRef fromString(String s) throws JsonSchemaException
JsonSchemaExceptionpublic static JsonRef emptyRef()
public boolean isEmpty()
public boolean isAbsolute()
public URI getRootAsURI()
public JsonFragment getFragment()
If there is no fragment, an empty string is returned.
public boolean contains(JsonRef other)
Copyright © 2012. All Rights Reserved.