net.sf.okapi.common

## Class NSContextManager

- java.lang.Object
- - net.sf.okapi.common.NSContextManager

- All Implemented Interfaces:
    javax.xml.namespace.NamespaceContext

      public class NSContextManager
      extends java.lang.Object
      implements javax.xml.namespace.NamespaceContext

  Helper class to manage XML namespaces. The reserved `xml` and `xmlns` prefixes are hard-coded.

  The following namespaces are pre-defined:

  - xml : http://www.w3.org/XML/1998/namespace
  - xmlns : http://www.w3.org/2000/xmlns/
  - xsl : http://www.w3.org/1999/XSL/Transform

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `NSContextManager()` Creates a new NSContextManager object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(java.lang.String prefix, java.lang.String uri)` Adds a prefix/uri pair to the manager.
    `java.lang.String` | `getNamespaceURI(java.lang.String prefix)` Gets the namespace URI for a given prefix.
    `java.lang.String` | `getPrefix(java.lang.String uri)` Gets the prefix for a given namespace URI.
    `java.util.Iterator<java.lang.String>` | `getPrefixes(java.lang.String uri)` Not implemented.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### NSContextManager

          public NSContextManager()

      Creates a new NSContextManager object.

  - ### Method Detail

    - #### getNamespaceURI

          public java.lang.String getNamespaceURI(java.lang.String prefix)

      Gets the namespace URI for a given prefix.
      Specified by:
        `getNamespaceURI` in interface `javax.xml.namespace.NamespaceContext`
      Parameters:
        `prefix` - The prefix to look up.
      Returns:
        The namespace URI for the given prefix, or XMLConstants.NULL_NS_URI if none was found.

    - #### getPrefix

          public java.lang.String getPrefix(java.lang.String uri)

      Gets the prefix for a given namespace URI.
      Specified by:
        `getPrefix` in interface `javax.xml.namespace.NamespaceContext`
      Parameters:
        `uri` - The namespace URI to look up.
      Returns:
        The prefix for the given namespace URI, or null the mamager has no such namespace URI defined.

    - #### getPrefixes

          public java.util.Iterator<java.lang.String> getPrefixes(java.lang.String uri)

      Not implemented.
      Specified by:
        `getPrefixes` in interface `javax.xml.namespace.NamespaceContext`
      Returns:
        Always null.

    - #### add

          public void add(java.lang.String prefix,
                 java.lang.String uri)

      Adds a prefix/uri pair to the manager. No checking is done for existing prefix: If the same is already defined, it will be overwritten.
      Parameters:
        `prefix` - The prefix of the namespace
        `uri` - The uri of the namespace