public class JsonReferenceTransformer extends Object
Note: The current implementation of this class has no checks for cyclic references. This
can lead to scenarios of infinite recursion and throwing of a StackOverflowError
.
Plans for mitigating this are in place and will be implemented within this class.
Modifier and Type | Field and Description |
---|---|
protected URI |
base
The URI of the referring document or directory where it is located.
|
protected JsonValue |
root
The root value of the referring document.
|
Constructor and Description |
---|
JsonReferenceTransformer(URI base,
JsonValue root)
Constructs a new JSON reference transformer.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
isResolvable(URI uri)
Returns
true if the specified URI can be resolved by this transformer. |
protected JsonValue |
resolve(URI uri)
Resolves the specified URI into a JSON value.
|
void |
transform(JsonValue value) |
protected URI base
protected JsonValue root
public JsonReferenceTransformer(URI base, JsonValue root) throws JsonReferenceException
If base
is null
then only absolute URI references or fragment-only
references can be resolved; an attempt to resolve a relative reference URI will throw
a JsonReferenceException
.
The purpose of root
is to allow fragment identifier references within the same
document without the need to resolve it via an absolute URI. If root
is null,
then fragment identifier references are constructed from base
, if specified.
base
- the base URI of the referring document.root
- the root value of the referring document.JsonReferenceException
- if base
is not null
and is not an absolute URI.protected boolean isResolvable(URI uri)
true
if the specified URI can be resolved by this transformer.
The default implementation returns false
. This method is intended to be
overridden by subclasses that can resolve particular types of URIs.
uri
- the URI to test to determine if it can be resolved.true
if the specified URI can be resolved by this transformer.protected JsonValue resolve(URI uri) throws JsonException
The default implementation throws a JsonException
. This method is intended to
be overridden by subclasses that can resolve particular types of URIs.
uri
- the URI to resolve.JsonException
- if the URI could not be resolved.public void transform(JsonValue value) throws JsonException
JsonException
Copyright © 2025 Open Identity Platform Community. All rights reserved.