org.jboss.xb.binding
Class NamespaceRegistry

java.lang.Object
  extended by org.jboss.xb.binding.NamespaceRegistry
All Implemented Interfaces:
javax.xml.namespace.NamespaceContext

public class NamespaceRegistry
extends Object
implements javax.xml.namespace.NamespaceContext

A simple namespace registry. It assignes namespace prefixes of the form 'ns?' where ? is an incrementing integer. registerURI(String,String) [TODO] cleanup the api

Since:
08-June-2004
Author:
Thomas.Diesler@jboss.org, Alexey Loubyansky, Anil Saldhana

Constructor Summary
NamespaceRegistry()
           
 
Method Summary
 void addPrefixMapping(String prefix, String nsURI)
          Adds prefix mapping.
 String getNamespaceURI(String prefix)
          Get the nsURI for a given prefix, maybe null.
 String getPrefix(String nsURI)
          Returns the last mapping for the prefix or null if the prefix was not mapped.
 Iterator getPrefixes(String namespaceURI)
          Returns all prefixes for the given URI.
 Iterator getRegisteredPrefix()
          Return an iterator over all registered nsURIs.
 Iterator getRegisteredURIs()
          Return an iterator over all registered nsURIs.
 boolean isRegistered(String nsURI)
          True if the given nsURI is registered.
 javax.xml.namespace.QName registerQName(javax.xml.namespace.QName qname)
          Register a QName and return a QName that is guarantied to have a prefix
 String registerURI(String nsURI, String prefix)
          Register the given nsURI/prefix combination.
 void removePrefixMapping(String prefix)
          Removes the last mapping for the given prefix.
 void unregisterURI(String nsURI)
          Unregisters all prefix mappings for the given URI, not just the last one added.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamespaceRegistry

public NamespaceRegistry()
Method Detail

registerQName

public javax.xml.namespace.QName registerQName(javax.xml.namespace.QName qname)
Register a QName and return a QName that is guarantied to have a prefix


registerURI

public String registerURI(String nsURI,
                          String prefix)
Register the given nsURI/prefix combination. In case the prefix is null, it will be assigend.

Parameters:
nsURI - The nsURI
prefix - The corresponding prefix, maybe null
Returns:
A prefix, never null

addPrefixMapping

public void addPrefixMapping(String prefix,
                             String nsURI)
Adds prefix mapping.

Parameters:
prefix - prefix to map
nsURI - the URI to prefix to

removePrefixMapping

public void removePrefixMapping(String prefix)
Removes the last mapping for the given prefix.

Parameters:
prefix - the prefix to remove mapping for

unregisterURI

public void unregisterURI(String nsURI)
Unregisters all prefix mappings for the given URI, not just the last one added. todo what is this used for?

Parameters:
nsURI - the URI to unregister

isRegistered

public boolean isRegistered(String nsURI)
True if the given nsURI is registered.


getRegisteredURIs

public Iterator getRegisteredURIs()
Return an iterator over all registered nsURIs.


getRegisteredPrefix

public Iterator getRegisteredPrefix()
Return an iterator over all registered nsURIs.


getPrefix

public String getPrefix(String nsURI)
Returns the last mapping for the prefix or null if the prefix was not mapped.

Specified by:
getPrefix in interface javax.xml.namespace.NamespaceContext

getPrefixes

public Iterator getPrefixes(String namespaceURI)
Returns all prefixes for the given URI.

Specified by:
getPrefixes in interface javax.xml.namespace.NamespaceContext
Parameters:
namespaceURI - the URI to return prefixes for
Returns:
prefixes mapped to the URI

getNamespaceURI

public String getNamespaceURI(String prefix)
Get the nsURI for a given prefix, maybe null.

Specified by:
getNamespaceURI in interface javax.xml.namespace.NamespaceContext


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.