net.sf.okapi.lib.xliff2.its

## Class ITSItems

- java.lang.Object
- - net.sf.okapi.lib.xliff2.its.ITSItems

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

      public class ITSItems
      extends java.lang.Object
      implements java.lang.Iterable<IITSItem>

  Represents a collection of `IITSItem` objects.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ITSItems()` Creates an empty `ITSItems` object.
    `ITSItems(ITSItems original)` Copy constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(IITSItem item)` Adds (or sets) a new ITS data category instance in this collection.
    `void` | `clear()` Removes all entries in this collection.
    `<A extends DataCategory> IITSItem` | `get(java.lang.Class<A> dcType)` Gets the item for a given type of data category.
    `IITSItem` | `get(java.lang.String dcName)` Gets the item for a given data category name.
    `boolean` | `isEmpty()` Indicates if there is at least one entry in this collection.
    `java.util.Iterator<IITSItem>` | `iterator()` Returns an iterator for the items in this collection.
    `void` | `remove(IITSItem item)` Removes a given item from this collection.
    `int` | `size()` Gets the number of distinct data categories in this collection.

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

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

- - ### Constructor Detail

    - #### ITSItems

          public ITSItems()

      Creates an empty `ITSItems` object.

    - #### ITSItems

          public ITSItems(ITSItems original)

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

  - ### Method Detail

    - #### iterator

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

      Returns an iterator for the items in this collection.
      Specified by:
        `iterator` in interface `java.lang.Iterable<IITSItem>`
      Returns:
        the iterator.

    - #### add

          public void add(IITSItem item)

      Adds (or sets) a new ITS data category instance in this collection.
      - If the data category is always single instance (like MT Confidence) this method replaces any existing instance by the new one.
      - If the data category allows for multiple instances (i.e. Provenance or Localization Quality Issue), this methods add the new instance. If an instance is already present, the existing instance is moved to a group and the new one is added to the group.
      Parameters:
        `item` - the new item to set.

    - #### isEmpty

          public boolean isEmpty()

      Indicates if there is at least one entry in this collection.
      Returns:
        true if there is at least one entry in this collection, false otherwise.

    - #### clear

          public void clear()

      Removes all entries in this collection.

    - #### remove

          public void remove(IITSItem item)

      Removes a given item from this collection. If the item is not found, nothing is done. For Provenance and Localization Quality Issue the item can be a group or an instance.
      Parameters:
        `item` - the item to remove.

    - #### size

          public int size()

      Gets the number of distinct data categories in this collection. Only one entry is counted for LocQualityIssue and Provenance, even if there are several.
      Returns:
        the number of distinct data categories in this collection.

    - #### get

          public IITSItem get(java.lang.String dcName)

      Gets the item for a given data category name. This method calls `get(Class)` after mapping the name to the class.
      Parameters:
        `dcName` - the name of the data category (as used in its:annotatorsRef).
      Returns:
        Same as for `get(Class)`.
      Throws:
        `InvalidParameterException` - if the name is not valid.

    - #### get

          public <A extends DataCategory> IITSItem get(java.lang.Class<A> dcType)

      Gets the item for a given type of data category.
      Parameters:
        `dcType` - the data category type.
      Returns:
        the item for the given type of data category, or null if there is none. The item returned is a group if there are several instances for the given data category (i.e. for multiple Provenance or Localization Quality Issue). That is: you may get a `Provenances` or a `LocQualityIssues` object when you query for the classes `Provenance` or `LocQualityIssue`.