com.smallx.xml.infoset
Class NamespaceScope

java.lang.Object
  extended bycom.smallx.xml.infoset.NamespaceScope

public class NamespaceScope
extends java.lang.Object

This class represents a namespace scope. An instance of this may be attached to a parent scope and represent a heirarchical chain of scopes.


Nested Class Summary
static class NamespaceScope.NotDeclared
          An exception throw when a prefix is not declared.
 
Constructor Summary
NamespaceScope(NamespaceScope parent, NamespaceDataProxy proxy)
          Constructs an empty namespace scope with a parent scope.
 
Method Summary
 Name expandName(java.lang.String name)
          Expands a qname into a name instance.
 Name expandName(java.lang.String name, boolean useDefault)
          Expands a qname into a name instance.
 Name expandName(java.lang.String name, boolean useDefault, NameTable table)
           
 NamespaceDataProxy getDataProxy()
          Sets the namespace scope's parent (very dangerous!).
 java.net.URI getNamespace(java.lang.String prefix)
          Returns an in-scope namespace name mapping for this prefix.
 java.lang.String getNearestPrefix(java.net.URI namespace)
          Returns the nearest in-scope prefix for a namespace name.
 NamespaceScope getParent()
          Returns the parent scope.
 java.lang.String getPrefix(Name name)
          Returns the appropriate prefix to use with the specified name.
 java.util.Iterator getPrefixes()
          Returns all the in-scope prefixes.
 java.lang.String toQName(Name nm, boolean element)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamespaceScope

public NamespaceScope(NamespaceScope parent,
                      NamespaceDataProxy proxy)
Constructs an empty namespace scope with a parent scope.

Parameters:
parent - The parent scope.
Method Detail

getParent

public NamespaceScope getParent()
Returns the parent scope.

Returns:
The parent namespace scope or null if there is no such scope.

getDataProxy

public NamespaceDataProxy getDataProxy()
Sets the namespace scope's parent (very dangerous!).


expandName

public Name expandName(java.lang.String name)
                throws XMLException
Expands a qname into a name instance.

Parameters:
name - The qname value to expand.
Returns:
A name instance.
Throws:
XMLException - Throw when the prefix is not declared or the qname is invalid.

expandName

public Name expandName(java.lang.String name,
                       boolean useDefault)
                throws XMLException
Expands a qname into a name instance.

Parameters:
name - The qname value to expand.
useDefault - a flag indicating if the default should be used for names without prefixes.
Returns:
A name instance.
Throws:
XMLException - Throw when the prefix is not declared or the qname is invalid.

expandName

public Name expandName(java.lang.String name,
                       boolean useDefault,
                       NameTable table)
                throws XMLException
Throws:
XMLException

toQName

public java.lang.String toQName(Name nm,
                                boolean element)

getPrefixes

public java.util.Iterator getPrefixes()
Returns all the in-scope prefixes.

Returns:
An interation of string prefix values.

getNamespace

public java.net.URI getNamespace(java.lang.String prefix)
Returns an in-scope namespace name mapping for this prefix. This may include mappings from parent scopes.

Parameters:
prefix - The prefix string with which to search.
Returns:
A namespace name or null if there is no mapping.

getNearestPrefix

public java.lang.String getNearestPrefix(java.net.URI namespace)
Returns the nearest in-scope prefix for a namespace name. This may include mappings from parent scopes.

Parameters:
namespace - The namespace with which to search.
Returns:
A prefix value or null if there is no mapping.

getPrefix

public java.lang.String getPrefix(Name name)
                           throws NamespaceScope.NotDeclared
Returns the appropriate prefix to use with the specified name. This prefix value represents the nearest in-scope prefix or null to signify that no prefix value should be used as the result of the name being unqualified by a namespace name or that an appropriate default namespace is already in scope.

Parameters:
name - The name to use in the search.
Returns:
A prefix value or null if no prefix should be used.
Throws:
NamespaceScope.NotDeclared - Thrown when a namespace name is specified on the name and there is no in-scope prefix or default namespace name that matches the URI value.