com.topologi.diffx.sequence
Class PrefixMapping

java.lang.Object
  extended by com.topologi.diffx.sequence.PrefixMapping

public final class PrefixMapping
extends Object

Provides a mapping of namespace URIs to prefixes.

This class can be used to reconstruct the qualified element or attribute names.

Note that for each namespace URI there can only be one prefix.

Since:
0.7
Version:
12 May 2010
Author:
Christophe Lauret

Constructor Summary
PrefixMapping()
           
 
Method Summary
 void add(String uri, String prefix)
          Add the specified mapping if the namespace URI has not been mapped before.
 String getPrefix(String uri)
          Returns the prefix corresponding to the given namespace URI.
 Enumeration<String> getURIs()
          Returns an enumeration of the namespace URIs used in this mapping.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrefixMapping

public PrefixMapping()
Method Detail

add

public void add(String uri,
                String prefix)
         throws NullPointerException
Add the specified mapping if the namespace URI has not been mapped before.

This method will ensure that the mapping is actually unique, that is that the namespace URI correspond to one and only one prefix and that the prefix only corresponds to one and only one namespace URI.

Parameters:
uri - The namespace URI to map.
prefix - The prefix to use.
Throws:
NullPointerException - if the URI or prefix is null

getURIs

public Enumeration<String> getURIs()
Returns an enumeration of the namespace URIs used in this mapping.

Returns:
An enumeration of the namespace URIs used in this mapping.

getPrefix

public String getPrefix(String uri)
Returns the prefix corresponding to the given namespace URI.

Parameters:
uri - The namespace URI to map.
Returns:
The corresponding prefix.