net.sf.okapi.lib.xliff2.core

## Class ExtAttributes

- java.lang.Object
- - net.sf.okapi.lib.xliff2.core.ExtAttributes

- All Implemented Interfaces:
    java.lang.Iterable<ExtAttribute>

      public class ExtAttributes
      extends java.lang.Object
      implements java.lang.Iterable<ExtAttribute>

  Represents a set of `ExtAttribute` objects and associated namespaces.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExtAttributes()` Creates a new empty `ExtAttributes` object.
    `ExtAttributes(ExtAttributes original)` Copy constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `deleteAttribute(java.lang.String namespaceURI, java.lang.String localName)` Removes an attribute from this set.
    `ExtAttribute` | `getAttribute(java.lang.String namespaceURI, java.lang.String localName)` Gets an attribute if it exists.
    `java.lang.String` | `getAttributeValue(java.lang.String namespaceURI, java.lang.String localName)` Gets the value for a given attribute name of a given namespace.
    `java.lang.String` | `getNamespacePrefix(java.lang.String namespaceURI)` Gets the prefix for a given namespace URI.
    `java.util.Set<java.lang.String>` | `getNamespaces()` Gets the set of keys for the namespaces in this object.
    `boolean` | `hasNamespace()` Indicates if this set has at least one namespace defined.
    `boolean` | `isEmpty()` Indicates if this set is empty or not.
    `java.util.Iterator<ExtAttribute>` | `iterator()` Creates an iterator for the attributes in this set.
    `ExtAttribute` | `setAttribute(ExtAttribute attribute)` Sets a given attribute in this set.
    `ExtAttribute` | `setAttribute(java.lang.String localName, java.lang.String value)` Sets an attribute without namespace for this set.
    `ExtAttribute` | `setAttribute(java.lang.String namespaceURI, java.lang.String localName, java.lang.String value)` Sets an attribute in this set.
    `void` | `setNamespace(java.lang.String prefix, java.lang.String namespaceURI)` Sets a namespace in this set.
    `int` | `size()` Gets the number of attributes in this set.

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

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

- - ### Constructor Detail

    - #### ExtAttributes

          public ExtAttributes()

      Creates a new empty `ExtAttributes` object.

    - #### ExtAttributes

          public ExtAttributes(ExtAttributes original)

      Copy constructor.
      Parameters:
        `original` - the original object to duplicate.

  - ### Method Detail

    - #### getAttributeValue

          public java.lang.String getAttributeValue(java.lang.String namespaceURI,
                                           java.lang.String localName)

      Gets the value for a given attribute name of a given namespace.
      Parameters:
        `namespaceURI` - the namespace URI of the attribute.
        `localName` - the name of the attribute.
      Returns:
        the value (can be null), or null if not found.

    - #### getAttribute

          public ExtAttribute getAttribute(java.lang.String namespaceURI,
                                  java.lang.String localName)

      Gets an attribute if it exists.
      Parameters:
        `namespaceURI` - the namespace URI of the attribute QName.
        `localName` - the local name of the attribute.
      Returns:
        the attribute or null.

    - #### setAttribute

          public ExtAttribute setAttribute(ExtAttribute attribute)

      Sets a given attribute in this set. If an attribute with the same name and namespace URI already exists, the value of the existing one is replaced by the new one, but the attribute object itself is not changed.
      Parameters:
        `attribute` - the attribute to add/set.
      Returns:
        the set/added attribute (may be the attribute passed, or the existing one).

    - #### setAttribute

          public ExtAttribute setAttribute(java.lang.String namespaceURI,
                                  java.lang.String localName,
                                  java.lang.String value)

      Sets an attribute in this set. If an attribute with the same name and namespace URI already exists, the value of the existing one is replaced by the new one, but the attribute object itself is not changed.
      Parameters:
        `namespaceURI` - the namespace URI of the attribute.
        `localName` - the name of the attribute.
        `value` - the value of the attribute.
      Returns:
        the set/added attribute.

    - #### setAttribute

          public ExtAttribute setAttribute(java.lang.String localName,
                                  java.lang.String value)

      Sets an attribute without namespace for this set. (this means the attribute will be part of the namespace of the element where it is defined).
      Parameters:
        `localName` - the name of the attribute.
        `value` - the value of the attribute.
      Returns:
        the new attribute.

    - #### deleteAttribute

          public void deleteAttribute(java.lang.String namespaceURI,
                             java.lang.String localName)

      Removes an attribute from this set. If the attribute is not found, nothing is done.
      Parameters:
        `namespaceURI` - the namespace URI of the attribute.
        `localName` - the name of the attribute.

    - #### isEmpty

          public boolean isEmpty()

      Indicates if this set is empty or not.
      Returns:
        true if this set is empty, false if not.

    - #### size

          public int size()

      Gets the number of attributes in this set.
      Returns:
        the number of attributes in this set.

    - #### iterator

          public java.util.Iterator<ExtAttribute> iterator()

      Creates an iterator for the attributes in this set.
      Specified by:
        `iterator` in interface `java.lang.Iterable<ExtAttribute>`
      Returns:
        a new iterator for the attributes in this set.

    - #### setNamespace

          public void setNamespace(java.lang.String prefix,
                          java.lang.String namespaceURI)

      Sets a namespace in this set.
      Parameters:
        `prefix` - the namespace prefix.
        `namespaceURI` - the namsepace URI.

    - #### getNamespacePrefix

          public java.lang.String getNamespacePrefix(java.lang.String namespaceURI)

      Gets the prefix for a given namespace URI.
      Parameters:
        `namespaceURI` - the namespace URI.
      Returns:
        the prefix for the given namespace URI, or null if not found.

    - #### hasNamespace

          public boolean hasNamespace()

      Indicates if this set has at least one namespace defined.
      Returns:
        true if this set has at least one namespace defined, false otherwise.

    - #### getNamespaces

          public java.util.Set<java.lang.String> getNamespaces()

      Gets the set of keys for the namespaces in this object.
      Returns:
        the set of keys for the namespaces in this object.