|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.github.fge.jsonschema.core.load.uri.URITranslatorConfigurationBuilder
public final class URITranslatorConfigurationBuilder
Builder for a URITranslatorConfiguration
Example:
final URITranslatorConfiguration cfg
= URITranslatorConfiguration.newBuilder()
.setNamespace("http://my.site/myschemas/")
.addPathRedirect("http://my.site/myschemas/", "resource:/com/foo/myschemas")
.addSchemaRedirect("http://some.other.site/schema.json", "resource:/com/foo/externalsite/schema.json")
.freeze();
When feeding this configuration into a LoadingConfiguration
(using LoadingConfigurationBuilder.setURITranslatorConfiguration(URITranslatorConfiguration)),
the following will take place for URI schema1.json#/definitions/def1:
http://my.site/myschemas/schema1.json#/definitions/def1;SchemaLoader will then be resource:/com/foo/myschemas/schema1.json#/definitions/def1.If URI http://some.other.site/schema.json#bar is encountered,
a schema redirect triggers and will yield URI resource:/com/foo/externalsite/schema.json#bar.
URITranslatorConfiguration,
SchemaLoader,
LoadingConfigurationBuilder.setURITranslatorConfiguration(URITranslatorConfiguration),
SchemaLoader.SchemaLoader(LoadingConfiguration)| Method Summary | |
|---|---|
URITranslatorConfigurationBuilder |
addPathRedirect(String from,
String to)
Convenience method for adding a path URI redirection |
URITranslatorConfigurationBuilder |
addPathRedirect(URI from,
URI to)
Add a path redirection |
URITranslatorConfigurationBuilder |
addSchemaRedirect(String from,
String to)
Convenience method for schema redirections |
URITranslatorConfigurationBuilder |
addSchemaRedirect(URI from,
URI to)
Add a schema redirection |
URITranslatorConfiguration |
freeze()
Obtain a frozen configuration from this builder |
URITranslatorConfigurationBuilder |
setNamespace(String uri)
Set the namespace for this configuration (convenience method) |
URITranslatorConfigurationBuilder |
setNamespace(URI uri)
Set the namespace for this configuration |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public URITranslatorConfigurationBuilder setNamespace(URI uri)
All schema loading via URIs (using SchemaLoader.get(URI) or
when encountering a JSON Reference in a schema) will be resolved against
the provided namespace.
uri - the URI
NullPointerException - URI is null
IllegalArgumentException - URI is not absolute, or is not a path
URI (ie, does not end with /)public URITranslatorConfigurationBuilder setNamespace(String uri)
This calls setNamespace(URI) after creating the URI using
URI.create(String).
uri - the URI
NullPointerException - argument is null
IllegalArgumentException - URI.create(String) failedsetNamespace(URI)
public URITranslatorConfigurationBuilder addSchemaRedirect(URI from,
URI to)
Schema redirection occurs after namespace resolution and after path redirection.
from - the URI to redirect fromto - the URI to redirect to
NullPointerException - one, or both, argument(s) is/are null
IllegalArgumentException - one, or both, URI(s) are not absolute
JSON References; or a redirection already exists for URI from; or
from and to are the same URI after normalization.
public URITranslatorConfigurationBuilder addSchemaRedirect(String from,
String to)
This calls addSchemaRedirect(URI, URI) after converting its
string arguments to URIs using URI.create(String).
from - the URI to redirect fromto - the URI to redirect to
NullPointerException - one, or both, argument(s) is/are null
IllegalArgumentException - URI.create(String) failed for
one or both argument(s)
public URITranslatorConfigurationBuilder addPathRedirect(URI from,
URI to)
What is called a "path URI" here is a URI which is absolute,
hierarchical, has no fragment part and whose path component ends with a
/.
from - the "path URI" to redirectto - the target "path URI"
NullPointerException - one, or both, argument(s) is/are null
IllegalArgumentException - one, or both, argument(s) is/are not
valid path URIs; or a path redirection already exists for from;
or from and to are the same URI after normalization.
public URITranslatorConfigurationBuilder addPathRedirect(String from,
String to)
This calls addPathRedirect(URI, URI) after performing URI.create(String) on both arguments.
from - the "path URI" to redirectto - the target "path URI"
NullPointerException - one, or both, argument(s) is/are null
IllegalArgumentException - URI.create(String) failedaddPathRedirect(URI, URI)public URITranslatorConfiguration freeze()
freeze in interface Thawed<URITranslatorConfiguration>URITranslatorConfiguration
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||