com.github.fge.jsonschema.core.load
Class SchemaLoader

java.lang.Object
  extended by com.github.fge.jsonschema.core.load.SchemaLoader

@ThreadSafe
public final class SchemaLoader
extends Object

JSON Schema loader

All schema registering and downloading is done through this class.

Note that if the id of a schema is not absolute (that is, the URI itself is absolute and it has no fragment part, or an empty fragment), then the whole schema will be considered anonymous.


Constructor Summary
SchemaLoader()
          Create a new schema loader with the default loading configuration
SchemaLoader(LoadingConfiguration cfg)
          Create a new schema loader with a given loading configuration
 
Method Summary
 SchemaTree get(URI uri)
          Get a schema tree from the given URI
 SchemaTree load(JsonNode schema)
          Create a new tree from a schema
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SchemaLoader

public SchemaLoader(LoadingConfiguration cfg)
Create a new schema loader with a given loading configuration

Parameters:
cfg - the configuration
See Also:
LoadingConfiguration, LoadingConfigurationBuilder

SchemaLoader

public SchemaLoader()
Create a new schema loader with the default loading configuration

Method Detail

load

public SchemaTree load(JsonNode schema)
Create a new tree from a schema

Note that it will always create an "anonymous" tree, that is a tree with an empty loading URI.

Parameters:
schema - the schema
Returns:
a new tree
Throws:
NullPointerException - schema is null
See Also:
Dereferencing.newTree(JsonNode)

get

public SchemaTree get(URI uri)
               throws ProcessingException
Get a schema tree from the given URI

Note that if the URI is relative, it will be resolved against this registry's namespace, if any.

Parameters:
uri - the URI
Returns:
a schema tree
Throws:
ProcessingException - URI is not an absolute JSON reference, or failed to dereference this URI
NullPointerException - URI is null

toString

public String toString()
Overrides:
toString in class Object