sk.uniba.euromath.document.schema
Class NameListCustom<T extends BaseRule,P extends IBaseRuleP>

java.lang.Object
  extended by sk.uniba.euromath.document.schema.NameListCustom<T,P>
Type Parameters:
T - the rule type. Must be instance of AttributeRule when P is instance of AttributeRuleP, and NewElementRule when P is instance of NewElementRuleP.
P - the rule type. Can be instance of AttributeRuleP or NewElementRuleP only.
All Implemented Interfaces:
INameList<T>

public final class NameListCustom<T extends BaseRule,P extends IBaseRuleP>
extends Object
implements INameList<T>

Maintains list of all creatable elements/attributes. It is not backed by a NameListP instance, it relies on the data provider.

Author:
Martin Vysny

Constructor Summary
NameListCustom(String localNamespaceUri)
          Creates instance of an empty namelist.
NameListCustom(String localNamespaceUri, INameListImplDataProvider<P> dataProvider)
          Creates instance of namelist from a provider.
NameListCustom(String localNamespaceUri, Map<QName,T> rules)
          Creates instance of namelist from a provider.
 
Method Summary
 boolean acceptsNamespace(String namespaceURI)
          Checks if the namelist accepts/contains at least one qname from given namespace.
 Set<QName> getForeignNames()
          Returns set of all foreign names, that are in this namelist.
 Set<String> getLocalNames()
          Returns set of all localnames, that are in this namelist.
 Set<String> getNamespaces()
          Tries to obtain a list of namespaces of qnames that are contained in this name list.
 String getNamespaceUri()
          Returns schema's namespace.
 T getRule(QName foreign)
          Returns rule, that can be used to create node content.
 T getRule(QName qname, boolean isElement)
          Returns rule, that can be used to create node content.
 T getRule(String localName)
          Returns rule, that can be used to create node content.
 boolean hasRule(QName qname, boolean isElement)
          Checks if this namelist contains given qname.
 boolean isEmpty()
          Checks if this namelist is empty (it contains no rules).
 boolean isLocal(QName qname, boolean isElement)
          Checks if given qname is local.
 void refresh()
          Refreshes the namelist to reflect the schema loading/unloading.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NameListCustom

public NameListCustom(String localNamespaceUri)
Creates instance of an empty namelist.

Parameters:
localNamespaceUri - the local namespace

NameListCustom

public NameListCustom(String localNamespaceUri,
                      INameListImplDataProvider<P> dataProvider)
Creates instance of namelist from a provider.

Parameters:
localNamespaceUri - the local namespace
dataProvider - the data provider.

NameListCustom

public NameListCustom(String localNamespaceUri,
                      Map<QName,T> rules)
Creates instance of namelist from a provider.

Parameters:
localNamespaceUri - the local namespace
rules - the rules map.
Method Detail

getLocalNames

public Set<String> getLocalNames()
Returns set of all localnames, that are in this namelist. This set must not be modified.

Specified by:
getLocalNames in interface INameList<T extends BaseRule>
Returns:
set of Strings.

getForeignNames

public Set<QName> getForeignNames()
Returns set of all foreign names, that are in this namelist. This set must not be modified.

Specified by:
getForeignNames in interface INameList<T extends BaseRule>
Returns:
set of QName

isEmpty

public boolean isEmpty()
Checks if this namelist is empty (it contains no rules).

Specified by:
isEmpty in interface INameList<T extends BaseRule>
Returns:
true if this namelist is empty.

getRule

public T getRule(String localName)
Returns rule, that can be used to create node content.

Specified by:
getRule in interface INameList<T extends BaseRule>
Parameters:
localName - local name of node (element or attribute).
Returns:
rule, that can be used to create node content. If node is attribute, then returned value is of type AttributeRule, else it is of type NewElementRule.

getRule

public T getRule(QName foreign)
Returns rule, that can be used to create node content.

Specified by:
getRule in interface INameList<T extends BaseRule>
Parameters:
foreign - full name of foreign (not from our namespace) node (element or attribute).
Returns:
rule, that can be used to create node content. If node is attribute, then returned value is of type AttributeRule, else it is of type NewElementRule.

getRule

public T getRule(QName qname,
                 boolean isElement)
Returns rule, that can be used to create node content. It automatically detects between local and foreign rule.

Specified by:
getRule in interface INameList<T extends BaseRule>
Parameters:
qname - full name of node (element or attribute).
isElement - true if the namelist represents element rules, false if attribute rules.
Returns:
rule, that can be used to create node content. If node is attribute, then returned value is of type AttributeRule, else it is of type NewElementRule.

getNamespaceUri

public String getNamespaceUri()
Returns schema's namespace.

Specified by:
getNamespaceUri in interface INameList<T extends BaseRule>
Returns:
base namespace of schema, that created this object.

acceptsNamespace

public boolean acceptsNamespace(String namespaceURI)
Description copied from interface: INameList
Checks if the namelist accepts/contains at least one qname from given namespace.

Specified by:
acceptsNamespace in interface INameList<T extends BaseRule>
Parameters:
namespaceURI - the namespace to check.
Returns:
true if the namelist accepts at least one qname with given namespace.

getNamespaces

public Set<String> getNamespaces()
Description copied from interface: INameList
Tries to obtain a list of namespaces of qnames that are contained in this name list. If the set cannot be computed then return null.

Specified by:
getNamespaces in interface INameList<T extends BaseRule>
Returns:
namespaces of items contained in the namelist, or null if it cannot be computed and/or represented. null namespace is represented as an empty string.

refresh

public void refresh()
Description copied from interface: INameList
Refreshes the namelist to reflect the schema loading/unloading.

Specified by:
refresh in interface INameList<T extends BaseRule>

hasRule

public boolean hasRule(QName qname,
                       boolean isElement)
Description copied from interface: INameList
Checks if this namelist contains given qname. It automatically detects between local and foreign rule.

Specified by:
hasRule in interface INameList<T extends BaseRule>
Parameters:
qname - full name of node (element or attribute).
isElement - true if the namelist represents element rules, false if attribute rules.
Returns:
true if given qname is known and there is a rule for it, false otherwise.

isLocal

public boolean isLocal(QName qname,
                       boolean isElement)
Description copied from interface: INameList
Checks if given qname is local.

Specified by:
isLocal in interface INameList<T extends BaseRule>
Parameters:
qname - full name of node (element or attribute).
isElement - true if the namelist represents element rules, false if attribute rules.
Returns:
true if given qname is local, false otherwise. It should implement the following algorithm: isElement ? DomTools.equalsURI(qname.getNamespaceURI(), getNamespaceUri()) : DomTools.equalsURI( qname.getNamespaceURI(), null);


Copyright © 2003-2006 null. All Rights Reserved.