Class AbstractStringList

java.lang.Object
org.apache.wicket.util.string.AbstractStringList
All Implemented Interfaces:
Serializable, IStringSequence
Direct Known Subclasses:
StringList

public abstract class AbstractStringList extends Object implements IStringSequence, Serializable
An abstract base class for string list implementations. Besides having an implementation for IStringSequence (iterator(), get(int index) and size()), an AbstractStringList can be converted to a String array or a List of Strings.

The total length of all Strings in the list can be determined by calling totalLength().

Strings or a subset of Strings in the list can be formatted using three join() methods:

  • join(String) Joins strings together using a given separator
  • join() Joins Strings using comma as a separator
  • join(int first, int last, String) Joins a sublist of strings using a given separator
Author:
Jonathan Locke
See Also:
  • Constructor Details

  • Method Details

    • iterator

      public abstract IStringIterator iterator()
      Specified by:
      iterator in interface IStringSequence
      Returns:
      String iterator
      See Also:
    • size

      public abstract int size()
      Specified by:
      size in interface IStringSequence
      Returns:
      Number of strings in this string list
      See Also:
    • get

      public abstract String get(int index)
      Description copied from interface: IStringSequence
      Gets a string at a given index in the sequence
      Specified by:
      get in interface IStringSequence
      Parameters:
      index - The index into this string list
      Returns:
      The string at the given index
      See Also:
    • toArray

      public String[] toArray()
      Returns this String sequence as an array of Strings. Subclasses may provide a more efficient implementation than the one provided here.
      Returns:
      An array containing exactly this sequence of Strings
    • toList

      public final List<String> toList()
      Returns this String sequence as an array of Strings. Subclasses may provide a more efficient implementation than the one provided here.
      Returns:
      An array containing exactly this sequence of Strings
    • totalLength

      public int totalLength()
      Returns:
      The total length of all Strings in this sequence.
    • join

      public final String join()
      Joins this sequence of strings using a comma separator. For example, if this sequence contains [1 2 3], the result of calling this method will be "1, 2, 3".
      Returns:
      The joined String
    • join

      public final String join(String separator)
      Joins this sequence of strings using a separator
      Parameters:
      separator - The separator to use
      Returns:
      The joined String
    • join

      public final String join(int first, int last, String separator)
      Joins this sequence of strings from first index to last using a separator
      Parameters:
      first - The first index to use, inclusive
      last - The last index to use, exclusive
      separator - The separator to use
      Returns:
      The joined String
    • toString

      public String toString()
      Converts this object to a string representation
      Overrides:
      toString in class Object
      Returns:
      String version of this object