|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection
java.util.AbstractList
java.util.AbstractSequentialList
java.util.LinkedList
com.ibm.are.common.GenericList
com.ibm.are.common.StringList
public class StringList
The StringList
class represents a list of java.lang.String
objects.
Because only strings are allowed to exist in the list, this class can provide a robust set
of methods to query, manipulate, and search the contents of the list. Many of the features
provided by this class allow users to choose between case sensitive or case insensitive
implementations.
Beyond list operations, this class also provides a standardized format for a string
representation of itself. This string representation can be provided by this class using
the GenericList.toString()
method, or can be parsed and built into a StringList
object
by this class using the parse(String)
method.
The string representation of this class has the following format:
Start of list marker is an open bracket: [
End of list marker is a close bracket: ]
Each item in the list is enclosed by single quotes. Typically items in the list are separated by a single space, but this is not a requirement.
Field Summary | |
---|---|
static java.lang.String |
COPYRIGHT
Copyright for class bytecode |
Fields inherited from class com.ibm.are.common.GenericList |
---|
DEFAULT_LIST_END_MARKER, DEFAULT_LIST_ITEM_END_MARKER, DEFAULT_LIST_ITEM_START_MARKER, DEFAULT_LIST_START_MARKER, listEndMarker, listItemEndMarker, listItemStartMarker, listStartMarker, maxInputListItems |
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
StringList()
Constructs an empty StringList object |
|
StringList(java.util.Collection c)
Constructs a StringList object and populates it with the
contents of the given collection. |
|
StringList(java.util.Iterator strListIter)
Constructs a StringList object and populates it with the
contents of all of the items in the provided iterator. |
|
StringList(java.lang.String theList)
Constructs a StringList object and populates it with the
contents of the string representation of a StringList specified
by the input parameter. |
|
StringList(java.lang.String[] theList)
Constructs a StringList object and populates it with the
contents of the provided string array. |
Method Summary | |
---|---|
void |
addAll(java.util.Iterator strListIter)
Adds all of the items in the iterator to the list |
void |
addAll(java.lang.String theList)
Adds all of the items from the string representation of a StringList to this object's list. |
void |
addAll(java.lang.String[] theList)
Adds all of the strings in the array to the list |
boolean |
containsAllIgnoreCase(StringList otherList)
Searches the list of strings to see if the list contains all of the items in given list of strings. |
boolean |
containsIgnoreCase(java.lang.Object o)
Searches the list of strings to see if the list contains the given item. |
boolean |
containsIgnoreCase(StringList otherList)
Check if the list of strings contains every string in the given list. |
boolean |
equalsIgnoreCase(StringList otherList)
Compare whether the given list contains all the strings in this list and this list contains all the strings in the given list, regardless of the element order. |
StringList |
findElementsContainingText(java.lang.String theText)
Searches the list of strings for the specified text. |
protected StringList |
findElementsContainingText(java.lang.String theText,
boolean ignoreCase)
Implementation of the findElementsContainingText and
findElementsContainingTextIgnoreCase methods. |
StringList |
findElementsContainingTextIgnoreCase(java.lang.String theText)
Searches the list of strings for the specified text. |
static boolean |
isList(java.lang.String candidate)
Determines if the given string is a string representation of a StringList object. |
static StringList |
parse(java.lang.String str)
Parses the given string and creates a StringList object that
contains all of the items represented by the string. |
void |
removeAllIgnoreCase(StringList otherList)
Removes all items in the given list from the list of strings. |
java.lang.String |
removeIgnoreCase(java.lang.String item)
Removes the given item from the list of strings. |
java.lang.String[] |
toStringArray()
Puts the contents of the list of strings into an array of strings. |
Methods inherited from class com.ibm.are.common.GenericList |
---|
equals, getListEndMarker, getListItemEndMarker, getListItemStartMarker, getListStartMarker, initFields, setListEndMarker, setListItemEndMarker, setListItemStartMarker, setListStartMarker, toString |
Methods inherited from class java.util.LinkedList |
---|
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, toArray, toArray |
Methods inherited from class java.util.AbstractSequentialList |
---|
iterator |
Methods inherited from class java.util.AbstractList |
---|
hashCode, listIterator, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, isEmpty, removeAll, retainAll |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
containsAll, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList |
Field Detail |
---|
public static final java.lang.String COPYRIGHT
Constructor Detail |
---|
public StringList()
StringList
object
public StringList(java.util.Collection c)
StringList
object and populates it with the
contents of the given collection. If any items in the collection are not
strings, an IllegalArgumentException
exception is thrown.
c
- The collection of items to add to the newly created list
java.lang.IllegalArgumentException
- If any item in the collection is not a stringpublic StringList(java.lang.String theList)
StringList
object and populates it with the
contents of the string representation of a StringList
specified
by the input parameter.
theList
- A string representation of a StringList
whose items
should be added to the newly constructed StringList
object.
java.lang.IllegalArgumentException
- If the input parameter is not a string
representation of a StringList
public StringList(java.lang.String[] theList)
StringList
object and populates it with the
contents of the provided string array.
theList
- An array of strings to add to the newly constructed StringList
objectpublic StringList(java.util.Iterator strListIter)
StringList
object and populates it with the
contents of all of the items in the provided iterator. If any items in
the iterator are not strings, an IllegalArgumentException
exception is thrown.
strListIter
- An iterator whose contents are to be added to the
newly constructed StringList
object
java.lang.IllegalArgumentException
- If any item in the iterator is not a stringMethod Detail |
---|
public static StringList parse(java.lang.String str)
StringList
object that
contains all of the items represented by the string. If the provided string
is just a single string, and not a string representation of a StringList
,
then a new StringList
object is created and the string itself
is added as the list's only item.
str
- The string to parse and build a StringList
from
StringList
object that all of the items represented by the stringpublic static boolean isList(java.lang.String candidate)
StringList
object.
candidate
- The string to inspect
true
if the given string is a string representation
of a StringList
object, false
if it is not.public void addAll(java.lang.String theList)
StringList
to this object's list.
theList
- The string representation of a StringList
java.lang.IllegalArgumentException
- If the input parameter is not a string
representation of a StringList
public void addAll(java.lang.String[] theList)
theList
- Array of strings to add to the listpublic void addAll(java.util.Iterator strListIter)
strListIter
- An iterator whose contents are to be added to the list
java.lang.IllegalArgumentException
- If any item in the iterator is not a stringpublic boolean containsIgnoreCase(java.lang.Object o)
o
- The item to search for
true
if the given item is contained in the list,
false
if it is not. If the given item is null
or the item is not a string, false
is returned.public boolean containsAllIgnoreCase(StringList otherList)
otherList
- The list of items to search for in the list of strings
true
if the list of items to search for are all contained
in the list of strings, false
if they are not.public boolean equalsIgnoreCase(StringList otherList)
otherList
- The list to compare against for equality
true
if the two lists are equal (ignoring case), false
if they are not equal.public boolean containsIgnoreCase(StringList otherList)
otherList
- The list to search
true
if this list contains every string in the given
list, false
if it does not. If the given list is empty,
true
is returned.public java.lang.String removeIgnoreCase(java.lang.String item)
item
- The item to remove from the list of strings
null
if the given item was not found in the list.public void removeAllIgnoreCase(StringList otherList)
otherList
- The list of strings to removepublic java.lang.String[] toStringArray()
public StringList findElementsContainingText(java.lang.String theText)
StringList
and returned.
theText
- The text to find within each item in the list of strings
StringList
containing all items in
the list that contain the specified text. If no items were found
that match the specified text, an empty list is returned.public StringList findElementsContainingTextIgnoreCase(java.lang.String theText)
StringList
and returned. Comparisons done to between the
given text and the items in the list of strings are done in a case
insensitive manner.
theText
- The text to find within each item in the list of strings
StringList
containing all items in
the list that contain the specified text. If no items were found
that match the specified text, an empty list is returned.protected StringList findElementsContainingText(java.lang.String theText, boolean ignoreCase)
findElementsContainingText
and
findElementsContainingTextIgnoreCase
methods.
theText
- The text to search forignoreCase
- Whether or not the search is case sensitive
StringList
containing all items in
the list that contain the specified text. If no items were found
that match the specified text, an empty list is returned.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |