java.lang.Object
org.apache.wicket.util.string.AbstractStringList
- All Implemented Interfaces:
Serializable
,IStringSequence
- Direct Known Subclasses:
StringList
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract String
get
(int index) Gets a string at a given index in the sequenceabstract IStringIterator
iterator()
final String
join()
Joins this sequence of strings using a comma separator.final String
Joins this sequence of strings from first index to last using a separatorfinal String
Joins this sequence of strings using a separatorabstract int
size()
String[]
toArray()
Returns this String sequence as an array of Strings.toList()
Returns this String sequence as an array of Strings.toString()
Converts this object to a string representationint
-
Constructor Details
-
AbstractStringList
public AbstractStringList()
-
-
Method Details
-
iterator
- Specified by:
iterator
in interfaceIStringSequence
- Returns:
- String iterator
- See Also:
-
size
- Specified by:
size
in interfaceIStringSequence
- Returns:
- Number of strings in this string list
- See Also:
-
get
Description copied from interface:IStringSequence
Gets a string at a given index in the sequence- Specified by:
get
in interfaceIStringSequence
- Parameters:
index
- The index into this string list- Returns:
- The string at the given index
- See Also:
-
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
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
- Returns:
- The total length of all Strings in this sequence.
-
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
Joins this sequence of strings using a separator- Parameters:
separator
- The separator to use- Returns:
- The joined String
-
join
Joins this sequence of strings from first index to last using a separator- Parameters:
first
- The first index to use, inclusivelast
- The last index to use, exclusiveseparator
- The separator to use- Returns:
- The joined String
-
toString
Converts this object to a string representation
-