Package opennlp.tools.util

# Class StringList

java.lang.Object
opennlp.tools.util.StringList

All Implemented Interfaces:
  `Iterable<String>`

public class StringList extends Object implements Iterable<String>
A `StringList` is an immutable list of `String`s.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StringList(boolean isCaseSensitive, String... tokens)`
  Initializes a `StringList` instance.
  `StringList(String singleToken)`
  Initializes a `StringList` instance.
  `StringList(String... tokens)`
  Initializes a `StringList` instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `compareToIgnoreCase(StringList tokens)`
  Compares to `token list` and ignores the case of the tokens.
  `boolean`
  `equals(Object obj)`
  `String`
  `getToken(int index)`
  `int`
  `hashCode()`
  `boolean`
  `isCaseSensitive()`
  `Iterator<String>`
  `iterator()`
  `int`
  `size()`
  `StringList`
  `toCaseInsensitive()`
  `StringList`
  `toCaseSensitive()`
  `String`
  `toString()`

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

  `getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Constructor Details

  - ### StringList

    public StringList(String singleToken)
    Initializes a `StringList` instance. By default, this instance is case-sensitive.

    Note:
    Token String will be interned via `StringInterners`.

    Parameters:
      `singleToken` - One single token

  - ### StringList

    public StringList(String... tokens)
    Initializes a `StringList` instance. By default, this instance is case-sensitive.

    Note:
    Token Strings will be interned via `StringInterners`.

    Parameters:
      `tokens` - The string parts of the new `StringList`. Must not be an empty tokens array or `null`.
    Throws:
      `IllegalArgumentException` - Thrown if parameters were invalid.

  - ### StringList

    public StringList(boolean isCaseSensitive, String... tokens)
    Initializes a `StringList` instance.

    Note:
    Token Strings will be interned via `StringInterners`.

    Parameters:
      `isCaseSensitive` - Whether it will operate case-sensitive, or not.
      `tokens` - The string parts of the new `StringList`. Must not be an empty tokens array or `null`.
    Throws:
      `IllegalArgumentException` - Thrown if parameters were invalid.

- ## Method Details

  - ### getToken

    public String getToken(int index)
    Parameters:
      `index` - The index to get a token from.
    Returns:
      Retrieves a token from the given `index`.

  - ### size

    public int size()
    Returns:
      Retrieves the number of tokens inside this list.

  - ### iterator

    public Iterator<String> iterator()
    Specified by:
      `iterator` in interface `Iterable<String>`
    Returns:
      Retrieves an `Iterator` over all tokens.

  - ### compareToIgnoreCase

    public boolean compareToIgnoreCase(StringList tokens)
    Compares to `token list` and ignores the case of the tokens. Note: This can cause problems with some locales.
    Parameters:
      `tokens` - The `tokens` used for comparison.
    Returns:
      `true` if identically with ignore the case, `false` otherwise.

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`
    Returns:
      A human-readable representation of this `StringList`.

  - ### isCaseSensitive

    public boolean isCaseSensitive()
    Returns:
      `true`, if this `StringList` is case-sensitive.

  - ### toCaseInsensitive

    public StringList toCaseInsensitive()
    Returns:
      If this `StringList` is case-insensitive, the same instance is returned. Otherwise, a new object is returned.

  - ### toCaseSensitive

    public StringList toCaseSensitive()
    Returns:
      If this `StringList` is case-sensitive, the same instance is returned. Otherwise, a new object is returned.