net.sf.okapi.lib.xliff2

## Class NSContext

- java.lang.Object
- - net.sf.okapi.lib.xliff2.NSContext

- All Implemented Interfaces:
    java.lang.Cloneable, javax.xml.namespace.NamespaceContext

      public class NSContext
      extends java.lang.Object
      implements javax.xml.namespace.NamespaceContext, java.lang.Cloneable

  Represents the context of the namespaces at a specific point during reading or writing of an XLIFF document. The namespaces http://www.w3.org/XML/1998/namespace and http://www.w3.org/2000/xmlns/ are pre-defined. This class implements the `NamespaceContext` interface.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `NSContext()` Creates a new object.
    `NSContext(java.lang.String prefix, java.lang.String uri)` Creates a new context object and add one namespace to it.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `NSContext` | `clone()`
    `boolean` | `containsPair(java.lang.String prefix, java.lang.String uri)` Indicates if this context has a given namespace URI associated with a given prefix.
    `java.lang.String` | `getNamespaceURI(java.lang.String prefix)`
    `java.lang.String` | `getPrefix(java.lang.String uri)`
    `java.util.Iterator<java.lang.String>` | `getPrefixes(java.lang.String uri)`
    `void` | `put(java.lang.String prefix, java.lang.String uri)` Sets a prefix/uri pair to this context.
    `java.lang.String` | `toString()`

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

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

- - ### Constructor Detail

    - #### NSContext

          public NSContext()

      Creates a new object.

    - #### NSContext

          public NSContext(java.lang.String prefix,
                   java.lang.String uri)

      Creates a new context object and add one namespace to it.
      Parameters:
        `prefix` - the prefix of the namespace to add.
        `uri` - the namespace URI.

  - ### Method Detail

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### clone

          public NSContext clone()

      Overrides:
        `clone` in class `java.lang.Object`

    - #### getNamespaceURI

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

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

    - #### getPrefix

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

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

    - #### getPrefixes

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

      Specified by:
        `getPrefixes` in interface `javax.xml.namespace.NamespaceContext`

    - #### put

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

      Sets a prefix/uri pair to this context. 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.

    - #### containsPair

          public boolean containsPair(java.lang.String prefix,
                             java.lang.String uri)

      Indicates if this context has a given namespace URI associated with a given prefix.
      Parameters:
        `prefix` - the prefix to look for.
        `uri` - the URI to look for.
      Returns:
        treu of the pair is in the context, false otherwise.