Class JsonSchemaMap

All Implemented Interfaces:
Serializable, ConcurrentMap<URI,JsonSchema>, Map<URI,JsonSchema>

public abstract class JsonSchemaMap extends ConcurrentHashMap<URI,JsonSchema>
A container for retrieving JSON JsonSchema objects by URI.

Subclasses must implement one of the following methods to load schemas from external sources:

  • Constructor Details

  • Method Details

    • get

      public JsonSchema get(Object uri)
      Return the JsonSchema object at the specified URI.

      If this schema object has not been loaded yet, calls load(URI).

      The value can be of any of the following types: URI, URL, String. Strings must be valid URIs.

      URIs defined by UriResolver can be used for values.

      Specified by:
      get in interface Map<URI,JsonSchema>
      Overrides:
      get in class ConcurrentHashMap<URI,JsonSchema>
      Parameters:
      uri - The URI of the schema to retrieve.
      Returns:
      The JsonSchema, or null if schema was not located and could not be loaded.
    • add

      public JsonSchemaMap add(JsonSchema... schemas)
      Convenience method for pre-populating this map with the specified schemas.

      The schemas passed in through this method MUST have their ID properties set.

      Parameters:
      schemas - The set of schemas to add to this map.
      Returns:
      This object.
      Throws:
      RuntimeException - If one or more schema objects did not have their ID property set.
    • load

      public JsonSchema load(URI uri)
      Subclasses must implement either this method or getReader(URI) to load the schema with the specified URI.

      It's up to the implementer to decide where these come from.

      The default implementation calls getReader(URI) and parses the schema document. If getReader(URI) returns null, this method returns null indicating this is an unreachable document.

      Parameters:
      uri - The URI to load the schema from.
      Returns:
      The parsed schema.
    • getReader

      public Reader getReader(URI uri)
      Subclasses must implement either this method or load(URI) to load the schema with the specified URI.

      It's up to the implementer to decide where these come from.

      The default implementation returns null.

      Parameters:
      uri - The URI to connect to and retrieve the contents.
      Returns:
      The reader from reading the specified URI.