Package org.dom4j.tree
Class NamespaceStack
java.lang.Object
org.dom4j.tree.NamespaceStack
NamespaceStack implements a stack of namespaces and optionally maintains a
cache of all the fully qualified names (
QName
) which are in
scope. This is useful when building or navigating a dom4j document.- Version:
- $Revision: 1.13 $
- Author:
- James Strachan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddNamespace
(String prefix, String uri) Adds a new namespace to the stackvoid
clear()
Clears the stackboolean
DOCUMENT ME!protected Namespace
createNamespace
(String prefix, String namespaceURI) Factory method to creeate new Namespace instances.protected QName
createQName
(String localName, String qualifiedName, Namespace namespace) Factory method to creeate new QName instances.protected Namespace
Attempts to find the current default namespace on the stack right now or returns null if one could not be foundgetAttributeQName
(String namespaceURI, String localName, String qualifiedName) getNamespace
(int index) DOCUMENT ME!getNamespaceForPrefix
(String prefix) DOCUMENT ME!DOCUMENT ME!pop()
Pops the most recently usedNamespace
from the stackPops a namepace from the stack with the given prefix and URIvoid
Adds a namepace to the stack with the given prefix and URIvoid
Pushes the given namespace onto the stack so that its prefix becomes available.protected QName
Adds the QName to the stack of available QNamesprotected Namespace
remove
(int index) Removes the namespace at the given index of the stackvoid
setDocumentFactory
(DocumentFactory documentFactory) int
size()
DOCUMENT ME!toString()
-
Constructor Details
-
NamespaceStack
public NamespaceStack() -
NamespaceStack
-
-
Method Details
-
push
Pushes the given namespace onto the stack so that its prefix becomes available.- Parameters:
namespace
- is theNamespace
to add to the stack.
-
pop
Pops the most recently usedNamespace
from the stack- Returns:
- Namespace popped from the stack
-
size
public int size()DOCUMENT ME!- Returns:
- the number of namespaces on the stackce stack.
-
clear
public void clear()Clears the stack -
getNamespace
DOCUMENT ME!- Parameters:
index
- DOCUMENT ME!- Returns:
- the namespace at the specified index on the stack
-
getNamespaceForPrefix
DOCUMENT ME!- Parameters:
prefix
- DOCUMENT ME!- Returns:
- the namespace for the given prefix or null if it could not be found.
-
getURI
DOCUMENT ME!- Parameters:
prefix
- DOCUMENT ME!- Returns:
- the URI for the given prefix or null if it could not be found.
-
contains
DOCUMENT ME!- Parameters:
namespace
- DOCUMENT ME!- Returns:
- true if the given prefix is in the stack.
-
getQName
-
getAttributeQName
-
push
Adds a namepace to the stack with the given prefix and URI- Parameters:
prefix
- DOCUMENT ME!uri
- DOCUMENT ME!
-
addNamespace
Adds a new namespace to the stack- Parameters:
prefix
- DOCUMENT ME!uri
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
pop
Pops a namepace from the stack with the given prefix and URI- Parameters:
prefix
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
toString
-
getDocumentFactory
-
setDocumentFactory
-
getDefaultNamespace
-
pushQName
protected QName pushQName(String localName, String qualifiedName, Namespace namespace, String prefix) Adds the QName to the stack of available QNames- Parameters:
localName
- DOCUMENT ME!qualifiedName
- DOCUMENT ME!namespace
- DOCUMENT ME!prefix
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
createQName
Factory method to creeate new QName instances. By default this method interns the QName- Parameters:
localName
- DOCUMENT ME!qualifiedName
- DOCUMENT ME!namespace
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
createNamespace
Factory method to creeate new Namespace instances. By default this method interns the Namespace- Parameters:
prefix
- DOCUMENT ME!namespaceURI
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
findDefaultNamespace
Attempts to find the current default namespace on the stack right now or returns null if one could not be found- Returns:
- DOCUMENT ME!
-
remove
Removes the namespace at the given index of the stack- Parameters:
index
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
getNamespaceCache
-