org.exolab.castor.xml

Class Namespaces

public final class Namespaces extends Object

A class for handling Namespace declaration and scoping

Version: $Revision: 1.2 $ $Date: 2003/03/03 09:57:18 $

Author: Keith Visco

Nested Class Summary
classNamespaces.Namespace
An internal class used to represent a namespace
classNamespaces.NamespaceEnumerator
A simple Enumeration for Namespace objects
Constructor Summary
Namespaces()
Creates a new Namespaces instance
Namespaces(Namespaces parent)
Creates a new Namespaces instance
Method Summary
voidaddNamespace(String prefix, String uri)
Adds the given namespace declaration to this Namespaces
NamespacescreateNamespaces()
Creates a new Namespaces instance with this Namespaces as the parent
voiddeclareAsAttributes(AttributeListImpl atts, boolean localOnly)
Declare the namespaces of this stack in as attributes.
EnumerationgetLocalNamespaces()
Returns an Enumeration of local namespace URIs for this Namespaces.
StringgetNamespacePrefix(String nsURI)
Returns the Namespace prefix associated with the given URI.
String[]getNamespacePrefixes(String nsURI)
Returns all namespace prefixes associated with the given URI, including those from parent scopes.
String[]getNamespacePrefixes(String nsURI, boolean local)
Returns the Namespace prefixes associated with the given URI.
StringgetNamespaceURI(String prefix)
Returns the Namespace URI associated with the given prefix
StringgetNonDefaultNamespacePrefix(String nsURI)
Returns the Namespace prefix associated with the given URI.
NamespacesgetParent()
Returns the parent Namespaces for this Namespaces instance.
voidsetParent(Namespaces namespaces)
Sets the parent Namespaces for this Namespaces instance.

Constructor Detail

Namespaces

public Namespaces()
Creates a new Namespaces instance

Namespaces

public Namespaces(Namespaces parent)
Creates a new Namespaces instance

Method Detail

addNamespace

public void addNamespace(String prefix, String uri)
Adds the given namespace declaration to this Namespaces

Parameters: prefix the namespace prefix uri the namespace URI to be associated with the given prefix

createNamespaces

public Namespaces createNamespaces()
Creates a new Namespaces instance with this Namespaces as the parent

declareAsAttributes

public void declareAsAttributes(AttributeListImpl atts, boolean localOnly)
Declare the namespaces of this stack in as attributes.

Parameters: atts the Attribute List to fill in.

getLocalNamespaces

public Enumeration getLocalNamespaces()
Returns an Enumeration of local namespace URIs for this Namespaces.

Returns: an Enumeration of local namespace URIs.

getNamespacePrefix

public String getNamespacePrefix(String nsURI)
Returns the Namespace prefix associated with the given URI. If multiple namespace prefixes have been declared, then the first one found is returned. To obtain all prefixes see #getNamespacePrefixes.

Parameters: nsURI the namespace URI to lookup

Returns: the namespace prefix associated with the given URI

getNamespacePrefixes

public String[] getNamespacePrefixes(String nsURI)
Returns all namespace prefixes associated with the given URI, including those from parent scopes.

Parameters: nsURI the namespace URI to lookup

Returns: the namespace prefixes associated with the given URI

getNamespacePrefixes

public String[] getNamespacePrefixes(String nsURI, boolean local)
Returns the Namespace prefixes associated with the given URI.

Parameters: nsURI the namespace URI to lookup local a boolean that when true indicates only the local scope is searched.

Returns: the namespace prefixes associated with the given URI

getNamespaceURI

public String getNamespaceURI(String prefix)
Returns the Namespace URI associated with the given prefix

Parameters: prefix the namespace prefix to lookup

Returns: the namespace URI associated with the given prefix

getNonDefaultNamespacePrefix

public String getNonDefaultNamespacePrefix(String nsURI)
Returns the Namespace prefix associated with the given URI. Or null if no prefix has been declared. This method will ignore the default namespace. This is useful when dealing with attributes that do not use the default namespace.

Parameters: nsURI the namespace URI to lookup

Returns: the namespace prefix associated with the given URI

getParent

public Namespaces getParent()
Returns the parent Namespaces for this Namespaces instance.

Returns: the parent Namespaces for this Namespaces instance.

setParent

public void setParent(Namespaces namespaces)
Sets the parent Namespaces for this Namespaces instance.

Parameters: namespaces the parent Namespaces

Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com