org.exolab.castor.xml
Class Namespaces
java.lang.Object
org.exolab.castor.xml.Namespaces
public final class Namespaces
extends java.lang.Object
A class for handling Namespace declaration and scoping
$Revision: 5951 $ $Date: 2004-09-09 23:04:08 -0600 (Thu, 09 Sep 2004) $
void | addNamespace(String prefix, String uri) - Adds the given namespace declaration to this Namespaces
|
Namespaces | createNamespaces() - Creates a new Namespaces instance with this Namespaces as the parent
|
void | declareAsAttributes(AttributeListImpl atts, boolean localOnly) - Declare the namespaces of this stack in as attributes.
|
Enumeration | getLocalNamespacePrefixes() - Returns all namespace prefixes declared locally
|
Enumeration | getLocalNamespaces() - Returns an Enumeration of local namespace URIs for this Namespaces.
|
String | getNamespacePrefix(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.
|
String | getNamespaceURI(String prefix) - Returns the Namespace URI associated with the given prefix
|
String | getNonDefaultNamespacePrefix(String nsURI) - Returns the Namespace prefix associated with the given URI.
|
Namespaces | getParent() - Returns the parent Namespaces for this Namespaces instance.
|
boolean | removeNamespace(String prefix) - Removes the namespace declaration for the given prefix.
|
void | sendEndEvents(ContentHandler handler) - Calls the given ContentHandler's endPrefixMapping method
for each locally declared namespace
|
void | sendStartEvents(ContentHandler handler) - Calls the given ContentHandler's startPrefixMapping method
for each locally declared namespace
|
void | setParent(Namespaces namespaces) - Sets the parent Namespaces for this Namespaces instance.
|
XML_NAMESPACE
public static final String XML_NAMESPACE
The reserved XML 1.0 Namespace URI
XML_NAMESPACE_PREFIX
public static final String XML_NAMESPACE_PREFIX
The reserved XML Namespace Prefix
Namespaces
public Namespaces()
Creates a new Namespaces instance
Namespaces
public Namespaces(Namespaces parent)
Creates a new Namespaces instance
addNamespace
public void addNamespace(String prefix,
String uri)
Adds the given namespace declaration to this Namespaces
prefix
- the namespace prefixuri
- 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.
atts
- the Attribute List to fill in.
getLocalNamespacePrefixes
public Enumeration getLocalNamespacePrefixes()
Returns all namespace prefixes declared locally
- an Enumeration of locally declared namespace prefixes
getLocalNamespaces
public Enumeration getLocalNamespaces()
Returns an Enumeration of local namespace URIs for this Namespaces.
- 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
.
nsURI
- the namespace URI to lookup
- 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.
nsURI
- the namespace URI to lookup
- 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.
nsURI
- the namespace URI to lookuplocal
- a boolean that when true indicates only the local
scope is searched.
- the namespace prefixes associated with the given URI
getNamespaceURI
public String getNamespaceURI(String prefix)
Returns the Namespace URI associated with the given prefix
prefix
- the namespace prefix to lookup
- 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.
nsURI
- the namespace URI to lookup
- the namespace prefix associated with the given URI
getParent
public Namespaces getParent()
Returns the parent Namespaces for this Namespaces instance.
- the parent Namespaces for this Namespaces instance.
removeNamespace
public boolean removeNamespace(String prefix)
Removes the namespace declaration for the given prefix.
This is a local action only, the namespace declaration
will not be removed from any parent Namespaces object.
prefix
- the namespace prefix to remove the binding of
- true if the namespace declaration was removed,
otherwise false.
sendEndEvents
public void sendEndEvents(ContentHandler handler)
throws SAXException
Calls the given ContentHandler's endPrefixMapping method
for each locally declared namespace
handler
- the ContentHandler
sendStartEvents
public void sendStartEvents(ContentHandler handler)
throws SAXException
Calls the given ContentHandler's startPrefixMapping method
for each locally declared namespace
handler
- the ContentHandler
setParent
public void setParent(Namespaces namespaces)
Sets the parent Namespaces for this Namespaces instance.
namespaces
- the parent Namespaces
Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com