com.github.fge.jsonschema.core.load.configuration
Class LoadingConfigurationBuilder

java.lang.Object
  extended by com.github.fge.jsonschema.core.load.configuration.LoadingConfigurationBuilder
All Implemented Interfaces:
Thawed<LoadingConfiguration>

public final class LoadingConfigurationBuilder
extends Object
implements Thawed<LoadingConfiguration>

Loading configuration (mutable instance)

See Also:
LoadingConfiguration

Method Summary
 LoadingConfigurationBuilder addParserFeature(JsonParser.Feature feature)
          Add a JsonParser feature
 LoadingConfigurationBuilder addScheme(String scheme, URIDownloader downloader)
          Add a new URI downloader
 LoadingConfigurationBuilder dereferencing(Dereferencing dereferencing)
          Set the dereferencing mode for this loading configuration
 LoadingConfiguration freeze()
          Freeze this configuration
 LoadingConfigurationBuilder preloadSchema(JsonNode schema)
          Preload a schema
 LoadingConfigurationBuilder preloadSchema(String uri, JsonNode schema)
          Preload a schema at a given URI
 LoadingConfigurationBuilder removeParserFeature(JsonParser.Feature feature)
          Remove a JSON parser feature
 LoadingConfigurationBuilder removeScheme(String scheme)
          Remove a downloader for a given scheme
 LoadingConfigurationBuilder setEnableCache(boolean enableCache)
          Should we enable caching of downloaded schemas
 LoadingConfigurationBuilder setURITranslatorConfiguration(URITranslatorConfiguration translatorCfg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setEnableCache

public LoadingConfigurationBuilder setEnableCache(boolean enableCache)
Should we enable caching of downloaded schemas

Note that this does not affect preloaded schemas

Parameters:
enableCache - if loaded schemas have to be cached
Returns:
this

addScheme

public LoadingConfigurationBuilder addScheme(String scheme,
                                             URIDownloader downloader)
Add a new URI downloader

Parameters:
scheme - the scheme
downloader - the downloader
Returns:
this
Throws:
NullPointerException - scheme or downloader is null
IllegalArgumentException - illegal scheme

removeScheme

public LoadingConfigurationBuilder removeScheme(String scheme)
Remove a downloader for a given scheme

Parameters:
scheme - the scheme
Returns:
this

setURITranslatorConfiguration

public LoadingConfigurationBuilder setURITranslatorConfiguration(URITranslatorConfiguration translatorCfg)

dereferencing

public LoadingConfigurationBuilder dereferencing(Dereferencing dereferencing)
Set the dereferencing mode for this loading configuration

By default, it is Dereferencing.CANONICAL.

Parameters:
dereferencing - the dereferencing mode
Returns:
this
Throws:
NullPointerException - dereferencing mode is null

preloadSchema

public LoadingConfigurationBuilder preloadSchema(String uri,
                                                 JsonNode schema)
Preload a schema at a given URI

Use this if the schema you wish to preload does not have an absolute id at the top level.

Note that the syntax of the schema is not checked at this stage.

Parameters:
uri - the URI to use
schema - the schema
Returns:
this
Throws:
NullPointerException - the URI or schema is null
IllegalArgumentException - a schema already exists at this URI
See Also:
JsonRef

preloadSchema

public LoadingConfigurationBuilder preloadSchema(JsonNode schema)
Preload a schema

Use this if the schema already has an absolute id.

Parameters:
schema - the schema
Returns:
this
Throws:
NullPointerException - schema is null
IllegalArgumentException - schema has no id, or its id is not an absolute JSON Reference
See Also:
JsonRef

addParserFeature

public LoadingConfigurationBuilder addParserFeature(JsonParser.Feature feature)
Add a JsonParser feature

Use this option to enable non-standard JSON schema source including comments, single quotes, unquoted field names, etc.

Parameters:
feature - the JsonParser feature to enable
Returns:
this
Throws:
NullPointerException - feature is null
See Also:
JsonParser.Feature

removeParserFeature

public LoadingConfigurationBuilder removeParserFeature(JsonParser.Feature feature)
Remove a JSON parser feature

Note that attempts to remove JsonParser.Feature.AUTO_CLOSE_SOURCE will be ignored for safety reasons.

Parameters:
feature - the feature to remove
Returns:
this
Throws:
NullPointerException - feature is null
See Also:
addParserFeature(JsonParser.Feature)

freeze

public LoadingConfiguration freeze()
Freeze this configuration

Specified by:
freeze in interface Thawed<LoadingConfiguration>
Returns:
a frozen copy of this builder