org.bibop.xml.utils
Class NamespacesTable

java.lang.Object
  |
  +--org.bibop.xml.utils.NamespacesTable

public class NamespacesTable
extends java.lang.Object

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

Version:
CVS $Revision: 1.1.2.1 $ $Date: 2002/10/07 08:17:53 $
Author:
Pierpaolo Fumagalli (Apache Software Foundation, Exoffice Technologies)

Nested Class Summary
static interface NamespacesTable.Declaration
          A namespace declaration.
private static class NamespacesTable.Entry
          The internal entry structure for this table.
static interface NamespacesTable.Name
          A namespace-aware name.
private static class NamespacesTable.NameImpl
          The default namespace-aware name declaration implementation
 
Field Summary
private  NamespacesTable.Entry entry
          The initial namespace declaration.
 
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
 

Field Detail

entry

private NamespacesTable.Entry entry
The initial namespace declaration.

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 2003 Bibop Research International. All Rights Reserved.