public class StringList extends Object
It can also be used to split Strings into re-used SubString values. This class is not synchronized.
Modifier and Type | Field and Description |
---|---|
int |
expandSize |
Constructor and Description |
---|
StringList()
Create an empty string list.
|
StringList(String text)
Create a new StringList and add text to it.
|
StringList(String text,
char separator)
Create a new StringList and split and add text to it.
|
Modifier and Type | Method and Description |
---|---|
char[] |
add(char[] chars) |
char[] |
add(char[] chars,
int offset,
int length) |
CharArray |
add(CharArray ca) |
String |
add(String str) |
SubString |
add(SubString str) |
void |
addNull() |
StringList |
cache() |
void |
cached() |
StringList |
clear() |
void |
ensureCapacity(int size) |
SubString |
get(int index,
SubString dest)
This may return null if the entry at the index is null.
|
static StringList |
getCached() |
static StringList |
getCached(Class splitterType) |
SubString |
getSplitter() |
CharArray |
getUserBuffer() |
StringList |
setSplitter(Class splitterClass) |
StringList |
setSplitter(SubString splitter) |
int |
size()
Return the number of individual Strings.
|
StringList |
split(char[] source,
int start,
int length,
char separator)
This splits text into SubStrings placed into this StringList, after clearing
the list initially.
|
StringList |
split(String source,
char separator)
This splits text into SubStrings placed into this StringList, after clearing
the list initially.
|
StringList |
split(String source,
int start,
int length,
char separator)
This splits text into SubStrings placed into this StringList, after clearing
the list initially.
|
boolean |
stringsAreBest()
Returns true if converting to a String array or a Vector of Strings will not
result in any String or SubString creation.
|
Object[] |
toBestText()
Return either an array of Strings or an array of SubStrings depending on
what stringsAreBest() returns.
|
Object |
toSingleStringOrStringArray()
Return either a single String or an array of Strings or null if none was added.
|
Object |
toSingleStringOrStringArray(String useForEmpty)
Return either a single String or an array of Strings or useForEmpty if none was added.
|
CharArray |
toString(CharArray dest,
String lineSeparator) |
String |
toString(String lineSeparator) |
StringBuffer |
toString(StringBuffer dest,
String lineSeparator) |
String[] |
toStringArray() |
String[] |
toStringArray(String[] dest,
int offset,
int length)
Convert all entries into Strings.
|
void |
toStringList(StringList destination)
Add all from this StringList to the destination in the most effecient way.
|
Vector |
toStrings(Vector dest)
Copy the added Strings as SubStrings into the provided destination Vector.
|
SubString[] |
toSubStringArray() |
SubString[] |
toSubStringArray(SubString[] dest,
int offset,
int length)
Convert all entries into SubStrings.
|
Vector |
toSubStrings(Vector dest)
Copy the added Strings as SubStrings into the provided destination Vector.
|
String[] |
toTempStringArray(boolean exactSize)
Convert all entries into String.
|
Vector |
toTempStrings()
Convert all entries into String.
|
SubString[] |
toTempSubStringArray(boolean exactSize)
Convert all entries into SubStrings.
|
Vector |
toTempSubStrings()
Convert all entries into SubStrings.
|
boolean |
tryAdd(Object obj)
Try to add a text object.
|
StringList |
zero()
This sets the number of items in the StringList to zero and
caches all the used SubStrings for future use.
|
public StringList()
public StringList(String text)
text
- the text to add.public StringList(String text, char separator)
text
- the text to split.separator
- the separator character.public int size()
public void ensureCapacity(int size)
public StringList zero()
public StringList clear()
public CharArray getUserBuffer()
public StringList setSplitter(SubString splitter)
public SubString getSplitter()
public StringList setSplitter(Class splitterClass)
public void addNull()
public boolean tryAdd(Object obj)
String, SubString, CharArray, char[], String[], SubString[]
obj
- a text object of the types specified above.public char[] add(char[] chars)
public char[] add(char[] chars, int offset, int length)
public void toStringList(StringList destination)
destination
- a non-null destination StringList.public StringList split(char[] source, int start, int length, char separator)
source
- start
- length
- separator
- public StringList split(String source, char separator)
source
- start
- length
- separator
- public StringList split(String source, int start, int length, char separator)
source
- start
- length
- separator
- public Vector toTempSubStrings()
public Vector toTempStrings()
public Vector toSubStrings(Vector dest)
dest
- a destination Vector to add the SubStrings to. The SubStrings
placed in the Vector are new and not re-used by the StringList.public Vector toStrings(Vector dest)
dest
- a destination Vector to add the SubStrings to. The SubStrings
placed in the Vector are not re-used by the StringList.public boolean stringsAreBest()
public Object[] toBestText()
public SubString[] toTempSubStringArray(boolean exactSize)
exactSize
- if this is true then the array will be the exact size
as the number of entries, if false then it may be larger, although all
extra elements will be null.public String[] toTempStringArray(boolean exactSize)
exactSize
- if this is true then the array will be the exact size
as the number of entries, if false then it may be larger, although all
extra elements will be null.public Object toSingleStringOrStringArray(String useForEmpty)
useForEmpty
- will be returned if nothing was added.public Object toSingleStringOrStringArray()
public String[] toStringArray()
public SubString[] toSubStringArray()
public String[] toStringArray(String[] dest, int offset, int length)
dest
- an optional destination String[].offset
- the location in the String to put the data.length
- the number of items to put in the destination.public SubString[] toSubStringArray(SubString[] dest, int offset, int length)
dest
- an optional destination SubString[].public SubString get(int index, SubString dest)
index
- the index of the SubString to retrieve.dest
- an optional destination SubString.public StringBuffer toString(StringBuffer dest, String lineSeparator)
public static StringList getCached(Class splitterType)
public static StringList getCached()
public StringList cache()
public void cached()