public class StringList
extends Object
implements Serializable, Cloneable
The ListBuilder class has better performance and is more convenient for creating lists.
This class is a revision of the TclList class made more convenient for use by not throwing exceptions except when attempting construction from improper text. The class does not offer the static list parsing methods that TclList does.
Constructor and Description |
---|
StringList()
construct an empty list
|
StringList(String listText)
Parse text that is formatted as a whitespace delimited list of elements.
|
Modifier and Type | Method and Description |
---|---|
String |
get(int n)
Retrieve an element from a list, indexing starts with 0.
|
String |
join()
return the string representation of your list created from
joining the elements.
|
String |
join(String separator)
Join using a specified separator string.
|
void |
lappend(String e)
add an element to the list end
|
void |
lappend(String e1,
String e2)
add 2 elements to the list end
|
void |
lappend(String e1,
String e2,
String e3)
add 3 elements to the list end
|
void |
lappend(String e1,
String e2,
String e3,
String e4)
add 4 elements to the list end
|
int |
length()
Return the count of list elements.
|
String |
lindex(int n)
Retrieve an element from a list, indexing starts with 0.
|
void |
linsert(String e,
int index)
Insert an element at index N, sliding existing elements +1.
|
int |
llength()
Return the count of list elements
|
static StringList |
newList(String listStart)
Construct a list beginning with the provided String value, returning null if the
initial text is not proper.
|
void |
remove(int index)
remove a single element from the list
|
void |
remove(int[] indexes)
remove multiple elements
|
void |
replace(int index,
String element)
Replace a single element in a list.
|
String[] |
split()
return the list elements as a String array
|
String |
toString() |
public StringList()
public StringList(String listText) throws ListFormatException
listText
- ListFormatException
- if the text is not a proper list because it
contains unmatched quotes or unmatched braces or similar format errors.public String get(int n)
public String join()
public String join(String separator)
public void lappend(String e)
public void lappend(String e1, String e2)
public void lappend(String e1, String e2, String e3)
public void lappend(String e1, String e2, String e3, String e4)
public int length()
public String lindex(int n)
public void linsert(String e, int index)
public int llength()
public static StringList newList(String listStart)
public void remove(int index)
public void remove(int[] indexes)
public void replace(int index, String element)
public String[] split()
public String toString()
toString
in class Object