JBoss XML Binding 2.0.3.GA

org.jboss.xb.binding
Class NamespaceRegistry

java.lang.Object
  extended by org.jboss.xb.binding.NamespaceRegistry
All Implemented Interfaces:
Serializable, NamespaceContext

public class NamespaceRegistry
extends Object
implements NamespaceContext, Serializable

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
See Also:
Serialized Form

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<String> getPrefixes(String namespaceURI)
          Returns all prefixes for the given URI.
 Iterator<String> getRegisteredPrefixes()
          Return an iterator over all registered nsURIs.
 Iterator<String> getRegisteredURIs()
          Return an iterator over all registered nsURIs.
 boolean isRegistered(String nsURI)
          True if the given nsURI is registered.
 QName registerQName(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.
 int size()
           
 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 QName registerQName(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<String> getRegisteredURIs()
Return an iterator over all registered nsURIs.


getRegisteredPrefixes

public Iterator<String> getRegisteredPrefixes()
Return an iterator over all registered nsURIs.


size

public int size()
Returns:
the number of registered URIs

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 NamespaceContext

getPrefixes

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

Specified by:
getPrefixes in interface 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 NamespaceContext

JBoss XML Binding 2.0.3.GA

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.