sk.uniba.euromath.document.schema
Class SchemaPool

java.lang.Object
  extended by sk.uniba.euromath.document.schema.SchemaPool

public final class SchemaPool
extends Object

Manages list of Schemas, one for each namespace URI. This object is Singleton; there is at most one instance in application. Thread-safe.

Author:
Martin Vysny

Method Summary
 ISchemaFactory getDefaultFactory()
          Returns instance of the default schema factory.
 Map<QName,IAttributeRuleP> getExportedAttributes(String localNamespace, IQNameAcceptor qnAcceptor)
          Returns Map of all known attributes, exported from foreign namespace, that given acceptor accepts.
 Map<QName,INewElementRuleP> getForeignRoots(IQNameAcceptor nameAcceptor)
           Returns Map of all known root elements from foreign namespaces, that given acceptor accepts.The function returns roots of loaded schemas only!
static SchemaPool getInstance()
          Provides singleton instance.
 Set<String> getKnownNamespaces()
          Computes and returns set of known namespace URIs for which a schema is loadable.
 Map<QName,INewElementRuleP> getRoots(String namespaceUri, IQNameAcceptor acceptor)
          Returns all possible root elements for given namespace.
 ISchema getSchema(String namespaceUri)
          Returns the global schema with specified namespace.
 ISchema getSchemaNull(String namespaceUri)
          Returns the global schema with specified namespace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static SchemaPool getInstance()
Provides singleton instance.

Returns:
the instance.

getDefaultFactory

public final ISchemaFactory getDefaultFactory()
Returns instance of the default schema factory.

Returns:
factory that instantiates schema from schema files registered in the config file.

getSchemaNull

public ISchema getSchemaNull(String namespaceUri)
Returns the global schema with specified namespace. If no schema is loaded for the namespace (or it had already been freed) then returns null.

Parameters:
namespaceUri - the namespace
Returns:
the global schema for the namespace or null if the schema is not loaded for the namespace.

getSchema

public ISchema getSchema(String namespaceUri)
Returns the global schema with specified namespace. If no schema is loaded for the namespace (or it had already been freed) then an exception is thrown.

Parameters:
namespaceUri - the namespace
Returns:
the global schema for the namespace. If the schema is not loaded for the namespace then IllegalArgumentException is thrown.

getForeignRoots

public Map<QName,INewElementRuleP> getForeignRoots(IQNameAcceptor nameAcceptor)

Returns Map of all known root elements from foreign namespaces, that given acceptor accepts.The function returns roots of loaded schemas only!

Parameters:
nameAcceptor - the QName acceptor.
Returns:
Map of all root elements, that are accepted by the acceptor.

getRoots

public Map<QName,INewElementRuleP> getRoots(String namespaceUri,
                                            IQNameAcceptor acceptor)
Returns all possible root elements for given namespace. The schema for the namespace must already be loaded.

Parameters:
namespaceUri - the namespace of required document.
acceptor - these root elements must be accepted by this acceptor. If null then all roots are accepted.
Returns:
map that maps QName to INewElementRuleP.

getExportedAttributes

public Map<QName,IAttributeRuleP> getExportedAttributes(String localNamespace,
                                                        IQNameAcceptor qnAcceptor)
Returns Map of all known attributes, exported from foreign namespace, that given acceptor accepts. The namelist maps QName to AttributeRuleP.

Parameters:
localNamespace - selects local namespace. All other namespaces are foreign. Only attributes from foreign namespaces are put in a result map, regardless of the acceptor.
qnAcceptor - selects qnames that can appear in the result map.
Returns:
Map containing all attributes, that are accepted by the acceptor.

getKnownNamespaces

public Set<String> getKnownNamespaces()
Computes and returns set of known namespace URIs for which a schema is loadable.

Returns:
unmodifiable set of namespace URIs. null namespace is represented as an empty string.


Copyright © 2003-2006 null. All Rights Reserved.