Class PrefixMapping

java.lang.Object
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
  • Field Details

    • mappings

      private final Map<String,String> mappings
      Maps namespace URIs to prefixes.
  • Constructor Details

    • PrefixMapping

      public PrefixMapping()
  • Method Details

    • 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.