org.ozoneDB.xml.dom4j.o3impl
Class NamespaceStack

java.lang.Object
  extended byorg.ozoneDB.xml.dom4j.o3impl.NamespaceStack

public class NamespaceStack
extends java.lang.Object

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.1 $
Author:
James Strachan

Constructor Summary
NamespaceStack(DocumentFactory documentFactory)
          Deprecated. Use NamespaceStack(NodeFactory) instead.
NamespaceStack(NodeFactory nodeFactory)
           
 
Method Summary
 Namespace addNamespace(java.lang.String prefix, java.lang.String uri)
          Adds a new namespace to the stack
 void clear()
          Clears the stack
 boolean contains(Namespace namespace)
           
protected  Namespace createNamespace(java.lang.String prefix, java.lang.String namespaceURI)
          Factory method to creeate new AbstractNamespace instances.
protected  QName createQName(java.lang.String localName, java.lang.String qualifiedName, Namespace namespace)
          Factory method to creeate new QName instances.
protected  Namespace findDefaultNamespace()
          Attempts to find the current default namespace on the stack right now or returns null if one could not be found
 QName getAttributeQName(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qualifiedName)
           
 Namespace getDefaultNamespace()
           
 DocumentFactory getDocumentFactory()
          Deprecated. Use getNodeFactory() instead
 AbstractNamespace getNamespace(int index)
           
protected  java.util.Map getNamespaceCache()
           
 Namespace getNamespaceForPrefix(java.lang.String prefix)
           
 NodeFactory getNodeFactory()
           
 QName getQName(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qualifiedName)
           
 java.lang.String getURI(java.lang.String prefix)
           
 Namespace pop()
          Pops the most recently used AbstractNamespace from the stack
 Namespace pop(java.lang.String prefix)
          Pops a namepace from the stack with the given prefix and URI
 void push(Namespace namespace)
          Pushes the given namespace onto the stack so that its prefix becomes available.
 void push(java.lang.String prefix, java.lang.String uri)
          Adds a namepace to the stack with the given prefix and URI
protected  QName pushQName(java.lang.String localName, java.lang.String qualifiedName, Namespace namespace, java.lang.String prefix)
          Adds the QName to the stack of available QNames
protected  Namespace remove(int index)
          Removes the namespace at the given index of the stack
 void setDocumentFactory(DocumentFactory documentFactory)
          Deprecated. Use setNodeFactory(NodeFactory) instead
 void setNodeFactory(NodeFactory nodeFactory)
           
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NamespaceStack

public NamespaceStack(DocumentFactory documentFactory)
Deprecated. Use NamespaceStack(NodeFactory) instead.


NamespaceStack

public NamespaceStack(NodeFactory nodeFactory)
Method Detail

push

public void push(Namespace namespace)
Pushes the given namespace onto the stack so that its prefix becomes available.

Parameters:
namespace - is the AbstractNamespace to add to the stack.

pop

public Namespace pop()
Pops the most recently used AbstractNamespace from the stack

Returns:
AbstractNamespace popped from the stack

size

public int size()
Returns:
the number of namespaces on the stackce stack.

clear

public void clear()
Clears the stack


getNamespace

public AbstractNamespace getNamespace(int index)
Returns:
the namespace at the specified index on the stack

getNamespaceForPrefix

public Namespace getNamespaceForPrefix(java.lang.String prefix)
Returns:
the namespace for the given prefix or null if it could not be found.

getURI

public java.lang.String getURI(java.lang.String prefix)
Returns:
the URI for the given prefix or null if it could not be found.

contains

public boolean contains(Namespace namespace)
Returns:
true if the given prefix is in the stack.

getQName

public QName getQName(java.lang.String namespaceURI,
                      java.lang.String localName,
                      java.lang.String qualifiedName)

getAttributeQName

public QName getAttributeQName(java.lang.String namespaceURI,
                               java.lang.String localName,
                               java.lang.String qualifiedName)

push

public void push(java.lang.String prefix,
                 java.lang.String uri)
Adds a namepace to the stack with the given prefix and URI


addNamespace

public Namespace addNamespace(java.lang.String prefix,
                              java.lang.String uri)
Adds a new namespace to the stack


pop

public Namespace pop(java.lang.String prefix)
Pops a namepace from the stack with the given prefix and URI


toString

public java.lang.String toString()

getDocumentFactory

public DocumentFactory getDocumentFactory()
Deprecated. Use getNodeFactory() instead


setDocumentFactory

public void setDocumentFactory(DocumentFactory documentFactory)
Deprecated. Use setNodeFactory(NodeFactory) instead


getNodeFactory

public NodeFactory getNodeFactory()

setNodeFactory

public void setNodeFactory(NodeFactory nodeFactory)

getDefaultNamespace

public Namespace getDefaultNamespace()

pushQName

protected QName pushQName(java.lang.String localName,
                          java.lang.String qualifiedName,
                          Namespace namespace,
                          java.lang.String prefix)
Adds the QName to the stack of available QNames


createQName

protected QName createQName(java.lang.String localName,
                            java.lang.String qualifiedName,
                            Namespace namespace)
Factory method to creeate new QName instances. By default this method interns the QName


createNamespace

protected Namespace createNamespace(java.lang.String prefix,
                                    java.lang.String namespaceURI)
Factory method to creeate new AbstractNamespace instances. By default this method interns the AbstractNamespace


findDefaultNamespace

protected Namespace findDefaultNamespace()
Attempts to find the current default namespace on the stack right now or returns null if one could not be found


remove

protected Namespace remove(int index)
Removes the namespace at the given index of the stack


getNamespaceCache

protected java.util.Map getNamespaceCache()


Copyright © 2004 The Ozone Database Project - www.ozone-db.org. All Rights Reserved.