de.hedenus.www
Class NamespaceContext

java.lang.Object
  extended by de.hedenus.www.NamespaceContext
All Implemented Interfaces:
java.io.Serializable

public class NamespaceContext
extends java.lang.Object
implements java.io.Serializable

Defines a namespace context for URIs.

Author:
Michael Hedenus
See Also:
Serialized Form

Nested Class Summary
static class NamespaceContext.Mapping
           
 
Constructor Summary
NamespaceContext(boolean useDefaults)
           
 
Method Summary
 NamespaceContext copy()
          Creates a copy of this namespace context.
 java.lang.String createAndDefineNamespacePrefix(java.lang.String uri)
          Heuristically creates a prefix and defines a new namespace-prefix mapping for the given URI.
 java.lang.String createQName(java.lang.String localName, java.lang.String namespaceURI)
          Creates a qualified name for the given local-name and the local-name's namespace URI.
 void defineNamespacePrefix(java.lang.String prefix, java.lang.String namespaceURI)
          Defines a new namespace-prefix mapping.
 java.util.Iterator getNamespaces()
          Returns all namespace URIs as iterator.
 java.lang.String getNamespaceURI(java.lang.String prefix)
          Returns the namespace URI for a prefix or null if prefix is not defined.
 java.lang.String getPrefix(java.lang.String namespaceURI)
          Returns the prefix for a namespace URI or null if namespaceURI is not defined.
 java.util.Iterator getPrefixes()
          Returns all prefixes as iterator.
 java.lang.String toShortForm(java.lang.String uri)
          Creates an abbreviated form of the URI or returns the URI itself (same object) if no appropriate namespace mapping is found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamespaceContext

public NamespaceContext(boolean useDefaults)
Method Detail

defineNamespacePrefix

public void defineNamespacePrefix(java.lang.String prefix,
                                  java.lang.String namespaceURI)
Defines a new namespace-prefix mapping.

Parameters:
prefix -
namespaceURI -

copy

public NamespaceContext copy()
Creates a copy of this namespace context.


getNamespaceURI

public java.lang.String getNamespaceURI(java.lang.String prefix)
Returns the namespace URI for a prefix or null if prefix is not defined.


getPrefix

public java.lang.String getPrefix(java.lang.String namespaceURI)
Returns the prefix for a namespace URI or null if namespaceURI is not defined.


getPrefixes

public java.util.Iterator getPrefixes()
Returns all prefixes as iterator.


getNamespaces

public java.util.Iterator getNamespaces()
Returns all namespace URIs as iterator.


createQName

public java.lang.String createQName(java.lang.String localName,
                                    java.lang.String namespaceURI)
Creates a qualified name for the given local-name and the local-name's namespace URI.

Parameters:
localName -
namespaceURI -

toShortForm

public java.lang.String toShortForm(java.lang.String uri)
Creates an abbreviated form of the URI or returns the URI itself (same object) if no appropriate namespace mapping is found.


createAndDefineNamespacePrefix

public java.lang.String createAndDefineNamespacePrefix(java.lang.String uri)
Heuristically creates a prefix and defines a new namespace-prefix mapping for the given URI.

Returns:
the generated prefix