sk.uniba.euromath.document.schema.impl.tools
Class NameClassTools

java.lang.Object
  extended by sk.uniba.euromath.document.schema.impl.tools.NameClassTools

public final class NameClassTools
extends Object

Serves as helper for SchemaImpl object. Introduces several useful methods, which works with com.sun.msv.grammar.NameClass classes. Intended to work only with org.w3c.dom.Document XML representation and com.sun.msv.grammar.NameClass expressions of Sun MSV package. Thread safe.

Author:
Martin Vysny

Field Summary
static com.sun.msv.grammar.NameClass ANY_ATTRIBUTE_NAMECLASS
          This nameclass accepts all attributes except attributes from these namespaces: EM_URI and Const.EM_URI_SELECT namespace.
static com.sun.msv.grammar.NameClass ANY_ELEMENT_NAMECLASS
          This nameclass accepts all elements except elements from these namespaces: Const.EM_URI.
 com.sun.msv.grammar.NameClass localAttributeNames
          Contains nameclass, that accepts all names from our namespace, and also all names with empty namespace.
 com.sun.msv.grammar.NameClass localElementNames
          Contains nameclass, that accepts all names from our namespace.
 com.sun.msv.grammar.NameClass localNamespaceNames
          Contains nameclass, that accepts all names from our namespace.
 String namespaceURI
          Namespace URI for which this instance works.
static com.sun.msv.grammar.NameClass NULL_NAMESPACE_NAMECLASS
          Accepts names with no (empty) namespace only.
 
Constructor Summary
NameClassTools(String namespaceURI)
          Constructor.
 
Method Summary
 boolean acceptsForeign(com.sun.msv.grammar.NameClass nc, boolean isElement)
          Checks, whether this nameclass accepts some foreign qnames.
static boolean acceptsFromNamespace(com.sun.msv.grammar.NameClass nc, String namespaceURI)
          Checks, whether the nameclass accepts some qnames from given namespace.
 boolean acceptsLocal(com.sun.msv.grammar.NameClass nc, boolean isElement)
          Checks, whether this nameclass accepts some local qnames.
 Set<String> getAcceptedLocalnames(com.sun.msv.grammar.NameClass nc, boolean isElement)
          Returns all local localnames that the nc accepts.
 String getLocalNamespace(boolean isElement)
          Returns local namespace for this schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

namespaceURI

public final String namespaceURI
Namespace URI for which this instance works.


NULL_NAMESPACE_NAMECLASS

public static final com.sun.msv.grammar.NameClass NULL_NAMESPACE_NAMECLASS
Accepts names with no (empty) namespace only.


ANY_ELEMENT_NAMECLASS

public static final com.sun.msv.grammar.NameClass ANY_ELEMENT_NAMECLASS
This nameclass accepts all elements except elements from these namespaces: Const.EM_URI.


ANY_ATTRIBUTE_NAMECLASS

public static final com.sun.msv.grammar.NameClass ANY_ATTRIBUTE_NAMECLASS
This nameclass accepts all attributes except attributes from these namespaces: EM_URI and Const.EM_URI_SELECT namespace.


localElementNames

public final com.sun.msv.grammar.NameClass localElementNames
Contains nameclass, that accepts all names from our namespace.


localAttributeNames

public final com.sun.msv.grammar.NameClass localAttributeNames
Contains nameclass, that accepts all names from our namespace, and also all names with empty namespace.


localNamespaceNames

public final com.sun.msv.grammar.NameClass localNamespaceNames
Contains nameclass, that accepts all names from our namespace.

Constructor Detail

NameClassTools

public NameClassTools(String namespaceURI)
Constructor.

Parameters:
namespaceURI - Namespace URI for which this instance works. The 'local' namespace.
Method Detail

getAcceptedLocalnames

public Set<String> getAcceptedLocalnames(com.sun.msv.grammar.NameClass nc,
                                         boolean isElement)
Returns all local localnames that the nc accepts.

Parameters:
nc - NameClass that accepts elements names.
isElement - if given nameclass is element's nameclass.
Returns:
set of Strings, representing valid local localname parts. Namespaces can be get via the getLocalNamespace() function.
Throws:
IllegalStateException - if given nameclass accepts infinite number of local localnames.

acceptsForeign

public boolean acceptsForeign(com.sun.msv.grammar.NameClass nc,
                              boolean isElement)
Checks, whether this nameclass accepts some foreign qnames.

Parameters:
nc - nameclass to check.
isElement - whether this nameclass is element's nameclass or attribute's nameclass.
Returns:
true if nc accepts foreign qname.

acceptsFromNamespace

public static boolean acceptsFromNamespace(com.sun.msv.grammar.NameClass nc,
                                           String namespaceURI)
Checks, whether the nameclass accepts some qnames from given namespace.

Parameters:
nc - nameclass to check.
namespaceURI - the namespace
Returns:
true if nc accepts at least one qname from given namespace.

acceptsLocal

public boolean acceptsLocal(com.sun.msv.grammar.NameClass nc,
                            boolean isElement)
Checks, whether this nameclass accepts some local qnames.

Parameters:
nc - nameclass to check.
isElement - whether this nameclass is element's nameclass or attribute's nameclass.
Returns:
true if nc accepts local qname also.

getLocalNamespace

public String getLocalNamespace(boolean isElement)
Returns local namespace for this schema.

Parameters:
isElement - if return namespace for local element, or local attribute.
Returns:
namespaceURI for element, or "" for attribute.


Copyright © 2003-2006 null. All Rights Reserved.