|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.wicket.util.string.AbstractStringList
org.apache.wicket.util.string.StringList
public final class StringList
A typesafe, mutable list of strings supporting a variety of convenient operations as well as expected operations from List such as add(), size(), remove(), iterator(), get(int index) and toArray(). Instances of the class are not threadsafe.
StringList objects can be constructed empty or they can be created using any of several static factory methods:
The tokenize() factory methods allow easy creation of StringLists via StringTokenizer. The repeat() static factory method creates a StringList that repeats a given String a given number of times.
The prepend() method adds a String to the beginning of the StringList. The removeLast() method pops a String off the end of the list. The sort() method sorts strings in the List using Collections.sort(). The class also inherits useful methods from AbstractStringList that include join() methods ala Perl and a toString() method which joins the list of strings with comma separators for easy viewing.
Constructor Summary | |
---|---|
StringList()
Constructor. |
|
StringList(int size)
Constructor. |
Method Summary | |
---|---|
void |
add(int pos,
String string)
Adds the string to the stringlist at position pos. |
void |
add(String string)
Adds a string to the back of this list. |
void |
add(StringValue value)
Adds a string value to this list as a string. |
boolean |
contains(String string)
|
String |
get(int index)
Gets the string at the given index. |
List<String> |
getList()
|
IStringIterator |
iterator()
Returns a typesafe iterator over this collection of strings. |
void |
prepend(String string)
Adds the given string to the front of the list. |
void |
remove(int index)
Removes the string at the given index. |
void |
removeLast()
Removes the last string in this list. |
static StringList |
repeat(int count,
String string)
Returns a list of a string repeated a given number of times. |
int |
size()
|
void |
sort()
Sorts this string list alphabetically. |
String[] |
toArray()
Converts this string list to a string array. |
static StringList |
tokenize(String string)
Extracts tokens from a comma and space delimited string. |
static StringList |
tokenize(String string,
String delimiters)
Extracts tokens from a delimited string. |
int |
totalLength()
|
static StringList |
valueOf(Collection<?> collection)
Converts a collection of objects into a list of string values by using the conversion methods of the StringValue class. |
static StringList |
valueOf(Object[] objects)
Converts an array of objects into a list of strings by using the object to string conversion method of the StringValue class. |
static StringList |
valueOf(String string)
Returns a string list with just one string in it. |
static StringList |
valueOf(String[] array)
Converts a string array to a string list. |
Methods inherited from class org.apache.wicket.util.string.AbstractStringList |
---|
join, join, join, toList, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public StringList()
public StringList(int size)
size
- Number of elements to preallocateMethod Detail |
---|
public static StringList repeat(int count, String string)
count
- The number of times to repeat the stringstring
- The string to repeat
public static StringList tokenize(String string)
string
- The string
public static StringList tokenize(String string, String delimiters)
string
- The stringdelimiters
- The delimiters
public static StringList valueOf(Collection<?> collection)
collection
- The collection to add as strings
public static StringList valueOf(Object[] objects)
objects
- The objects to convert
public static StringList valueOf(String string)
string
- The string
public static StringList valueOf(String[] array)
array
- The array
public void add(String string)
string
- String to addpublic void add(int pos, String string)
pos
- the position to add the string atstring
- the string to add.public void add(StringValue value)
value
- The value to addpublic boolean contains(String string)
string
- The string to look for
public String get(int index)
get
in interface IStringSequence
get
in class AbstractStringList
index
- The index
IndexOutOfBoundsException
IStringSequence.get(int)
public List<String> getList()
public IStringIterator iterator()
iterator
in interface IStringSequence
iterator
in class AbstractStringList
IStringSequence.iterator()
public void prepend(String string)
string
- The string to addpublic void remove(int index)
index
- The indexpublic void removeLast()
public int size()
size
in interface IStringSequence
size
in class AbstractStringList
IStringSequence.size()
public void sort()
public String[] toArray()
toArray
in class AbstractStringList
public int totalLength()
totalLength
in class AbstractStringList
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |