org.apache.cocoon.xml
Class NamespacesTable

java.lang.Object
  |
  +--org.apache.cocoon.xml.NamespacesTable

public class NamespacesTable
extends java.lang.Object

This utility class is used to keep track namespaces declarations and resolve namespaces names.

Version:
CVS $Id: NamespacesTable.java,v 1.4 2002/02/22 07:03:58 cziegeler Exp $
Author:
Pierpaolo Fumagalli (Apache Software Foundation, Exoffice Technologies)

Inner Class Summary
static interface NamespacesTable.Declaration
          A namespace declaration.
static interface NamespacesTable.Name
          A namespace-aware name.
 
Constructor Summary
NamespacesTable()
          Construct a new NamespacesTable instance.
 
Method Summary
 NamespacesTable.Declaration addDeclaration(java.lang.String prefix, java.lang.String uri)
          Declare a new namespace prefix-uri mapping.
 java.lang.String getPrefix(java.lang.String uri)
          Return one of the prefixes currently mapped to the specified URI or null.
 java.lang.String[] getPrefixes(java.lang.String uri)
          Return an array with all prefixes currently mapped to the specified URI.
 java.lang.String getUri(java.lang.String prefix)
          Return the URI associated with the given prefix or null if the prefix was not mapped.
 NamespacesTable.Declaration removeDeclaration(java.lang.String prefix)
          Undeclare a namespace prefix-uri mapping.
 NamespacesTable.Name resolve(java.lang.String uri, java.lang.String raw, java.lang.String prefix, java.lang.String local)
          Resolve a namespace-aware name against the current namespaces declarations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamespacesTable

public NamespacesTable()
Construct a new NamespacesTable instance.
Method Detail

addDeclaration

public NamespacesTable.Declaration addDeclaration(java.lang.String prefix,
                                                  java.lang.String uri)
Declare a new namespace prefix-uri mapping.
Returns:
The newly added Declaration.

removeDeclaration

public NamespacesTable.Declaration removeDeclaration(java.lang.String prefix)
Undeclare a namespace prefix-uri mapping.
If the prefix was previously declared mapping another URI, its value is restored.
Returns:
The removed Declaration or null.

getUri

public java.lang.String getUri(java.lang.String prefix)
Return the URI associated with the given prefix or null if the prefix was not mapped.

getPrefixes

public java.lang.String[] getPrefixes(java.lang.String uri)
Return an array with all prefixes currently mapped to the specified URI.
The array length might be zero if no prefixes are associated with the specified uri.
Returns:
A non-null String array.

getPrefix

public java.lang.String getPrefix(java.lang.String uri)
Return one of the prefixes currently mapped to the specified URI or null.

resolve

public NamespacesTable.Name resolve(java.lang.String uri,
                                    java.lang.String raw,
                                    java.lang.String prefix,
                                    java.lang.String local)
                             throws org.xml.sax.SAXException
Resolve a namespace-aware name against the current namespaces declarations.
Parameters:
uri - The namespace URI or null if not known.
raw - The raw (complete) name or null if not known.
prefix - The namespace prefix or null if not known.
local - The local name or null if not known.
Returns:
A non-null Name.
Throws:
org.xml.sax.SAXException - If the name cannot be resolved.


Copyright � 1999-2002 Apache Software Foundation. All Rights Reserved.