net.sf.okapi.lib.xliff2.core

## Class BaseList<T>

- java.lang.Object
- - net.sf.okapi.lib.xliff2.core.BaseList<T>

- Type Parameters:
    `T` - the type of item for this list (e.g. Note, Match, etc.).
  All Implemented Interfaces:
    java.lang.Iterable<T>
  Direct Known Subclasses:
    ChangeTrack, Glossary, Matches, Metadata, MetaGroup, Notes, Revision, Revisions, Validation

      public abstract class BaseList<T>
      extends java.lang.Object
      implements java.lang.Iterable<T>

  Provides the common methods for accessing and manipulating list-type objects such as the notes, the extension attributes, glossary, etc. Classes used as the type for the `BaseList` must be supported in the `CloneFactory`.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `BaseList()` Creates an empty `BaseList` object.
    `protected` | `BaseList(BaseList<T> original)` Copy constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `T` | `add(T object)` Adds an object to this list.
    `void` | `clear()` Removes all objects in this list.
    `T` | `get(int index)` Gets the object at a given index position.
    `boolean` | `isEmpty()` Indicates if this list is empty.
    `java.util.Iterator<T>` | `iterator()`
    `void` | `remove(int index)` Removes from this list the object at the given index position.
    `void` | `remove(T object)` Removes a given object from this list.
    `T` | `set(int index, T object)` Replaces an existing object by a new one at a given index position.
    `int` | `size()` Gets the number of objects in this list.

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

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

- - ### Constructor Detail

    - #### BaseList

          protected BaseList()

      Creates an empty `BaseList` object.

    - #### BaseList

          protected BaseList(BaseList<T> original)

      Copy constructor.
      Parameters:
        `original` - the original object to duplicate (can be null).

  - ### Method Detail

    - #### size

          public int size()

      Gets the number of objects in this list.
      Returns:
        the number of objects in this list.

    - #### isEmpty

          public boolean isEmpty()

      Indicates if this list is empty.
      Returns:
        true if there is no object in this list, false if there is one or more.

    - #### iterator

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

      Specified by:
        `iterator` in interface `java.lang.Iterable<T>`

    - #### clear

          public void clear()

      Removes all objects in this list.

    - #### add

          public T add(T object)

      Adds an object to this list.
      Parameters:
        `object` - the object to add.
      Returns:
        the object that was added.

    - #### remove

          public void remove(int index)

      Removes from this list the object at the given index position.
      Parameters:
        `index` - the index position.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the index is invalid.

    - #### remove

          public void remove(T object)

      Removes a given object from this list. If the object is not in the list nothing changes.
      Parameters:
        `object` - the object to remove.

    - #### get

          public T get(int index)

      Gets the object at a given index position.
      Parameters:
        `index` - the index position.
      Returns:
        the object at the given index.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the index is invalid.

    - #### set

          public T set(int index,
              T object)

      Replaces an existing object by a new one at a given index position.
      Parameters:
        `index` - the index position.
        `object` - the new object to set.
      Returns:
        the object that was set.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the index is invalid.