sk.baka.xml.schematic
Class SchemaReferences

java.lang.Object
  extended by sk.baka.xml.schematic.SchemaReferences

public final class SchemaReferences
extends Object

Manages list of ISchemas, one for each namespace URI, for a single document. Thread-safe. Allows you to instantiate and use custom schemas or schemas not registered in the SchemaPool.

Ensures that schema objects will not get garbage-collected while document has reference to this object.

Author:
Martin Vysny

Field Summary
 SchemaPool pool
          The validation context instance.
 
Constructor Summary
SchemaReferences(SchemaPool pool)
          Constructs new instance of schema references.
 
Method Summary
 ISchema getSchema(String namespaceURI)
           For given namespace URI returns appropriate Schema object, that validates elements with this namespace URI.
 SchemaAvailabilityEnum getSchemaAvailability(String namespaceURI)
          Determines availability of schema for the namespace.
 ISchema getSchemaNull(String namespaceURI)
           For given namespace URI returns appropriate Schema object, that validates elements with this namespace URI.
 void loadSchema(String namespaceURI)
          Loads schema for given namespace.
 void loadSchemas(Collection<? extends String> namespaces)
          Loads schemas for all given namespaces.
 void preserve(Set<? extends String> namespaces)
          Preserves only the schemas contained in the given set, but unregisters all other schemas.
 void unregisterSchema(String namespaceURI)
          Removes the schema from the reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pool

public final SchemaPool pool
The validation context instance.

Constructor Detail

SchemaReferences

public SchemaReferences(SchemaPool pool)
Constructs new instance of schema references.

Parameters:
pool - the validation context instance
Method Detail

getSchema

public ISchema getSchema(String namespaceURI)

For given namespace URI returns appropriate Schema object, that validates elements with this namespace URI.

If no local Schema for given URI exists for given document, then try to get appropriate global Schema (it won't attempt to load the schema if not present).

Parameters:
namespaceURI - namespace URI.
Returns:
Schema
Throws:
IllegalStateException - if Schema with given URI cannot be found.

getSchemaNull

public ISchema getSchemaNull(String namespaceURI)

For given namespace URI returns appropriate Schema object, that validates elements with this namespace URI.

If no local Schema for given URI exists for given document, then try to get appropriate global Schema (it won't attempt to load the schema if not present).

Parameters:
namespaceURI - namespace URI.
Returns:
Schema, or null if no such schema has been loaded.

loadSchemas

public void loadSchemas(Collection<? extends String> namespaces)
                 throws SchemaException,
                        IOException
Loads schemas for all given namespaces. If the schema is already loaded then it is not loaded again. It must be called before the Schema interface is used, to ensure that all schemata are properly loaded.

Parameters:
namespaces - collection of String namespaces.
Throws:
SchemaException - if error happens during loading of schemas.
IOException - if i/o error occurs during the schema files deserialization.

unregisterSchema

public void unregisterSchema(String namespaceURI)
Removes the schema from the reference. The schema may be still present, but only in a pool - it is not linked to this object anymore.

Parameters:
namespaceURI - the namespace.

loadSchema

public void loadSchema(String namespaceURI)
                throws SchemaException,
                       IOException
Loads schema for given namespace. If the schema is already loaded then it is not loaded again. It must be called before the Schema interface is used, to ensure that all schemata are properly loaded.

Parameters:
namespaceURI - the namespace
Throws:
SchemaException - if error happens during loading of schemas.
IOException - if i/o error occurs during the schema files deserialization.

getSchemaAvailability

public SchemaAvailabilityEnum getSchemaAvailability(String namespaceURI)
Determines availability of schema for the namespace.

Parameters:
namespaceURI - the namespace to check
Returns:
availability code.

preserve

public void preserve(Set<? extends String> namespaces)
Preserves only the schemas contained in the given set, but unregisters all other schemas.

Parameters:
namespaces - set of namespaces that shall be preserved.


Copyright © 2006 Martin Vysny - baka. All Rights Reserved.