org.apache.cocoon.components.serializers.util
Class Namespaces

java.lang.Object
  extended by org.apache.cocoon.components.serializers.util.Namespaces

public class Namespaces
extends Object

The Namespaces class is an utility class implementing a stack for XML namespaces declarations.

Version:
CVS $Id: Namespaces.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Pier Fumagalli, February 2003

Field Summary
static int NAMESPACE_PREFIX
          The index of the namespace prefix in for commit().
static int NAMESPACE_URI
          The index of the namespace uri in for commit().
 
Constructor Summary
Namespaces()
          Create a new Namespaces instance.
 
Method Summary
 String[][] commit()
          Checkpoint this stack, returning the list of all namespaces added since the last commit() or pop(...)
 String getPrefix(String nsuri)
          Return the namespace prefix associated with the specified URI.
 String getUri(String prefix)
          Return the namespace URI associated with the specified prefix.
 void pop(String prefix)
          Pop a new namespace declaration out of this stack.
 void push(String prefix, String uri)
          Push a new namespace declaration into this stack.
 String qualify(String nsuri, String local, String qualified)
          Qualify an XML name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACE_PREFIX

public static final int NAMESPACE_PREFIX
The index of the namespace prefix in for commit().

See Also:
Constant Field Values

NAMESPACE_URI

public static final int NAMESPACE_URI
The index of the namespace uri in for commit().

See Also:
Constant Field Values
Constructor Detail

Namespaces

public Namespaces()
Create a new Namespaces instance.

Method Detail

push

public void push(String prefix,
                 String uri)
Push a new namespace declaration into this stack.

Parameters:
prefix - The prefix to associate with the specified URI.
uri - The URI associated with the namespace.

pop

public void pop(String prefix)
         throws SAXException
Pop a new namespace declaration out of this stack.
If more than one namespace is associated with the specified namespace, only the last pushed namespace will be popped out.

Parameters:
prefix - The prefix to associate with the specified URI.
Throws:
SAXException - If the prefix was not mapped in this stack.

qualify

public String qualify(String nsuri,
                      String local,
                      String qualified)
               throws SAXException
Qualify an XML name.
Given a URI, local name and qualified name as passed to the SAX ContentHandler interface in the startElement() method, this method will always return a valid XML name token usable for serialization (checking namespaces URIs and prefixes).

Parameters:
nsuri - The Namespace URI, or the empty string if the element has no namespace URI or if namespace processing is not being performed.
local - The local name (without prefix), or the empty string if namespace processing is not being performed.
qualified - The qualified name (with prefix), or the empty string if qualified names are not available.
Throws:
SAXException - If the specified URI is not mapped with a prefix.

commit

public String[][] commit()
Checkpoint this stack, returning the list of all namespaces added since the last commit() or pop(...) call.


getUri

public String getUri(String prefix)
              throws SAXException
Return the namespace URI associated with the specified prefix.

Throws:
SAXException - If the prefix cannot be mapped.

getPrefix

public String getPrefix(String nsuri)
                 throws SAXException
Return the namespace prefix associated with the specified URI.

Throws:
SAXException - If the URI cannot be mapped.


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.