|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.collection.StringCollection
public class StringCollection
A StringCollection is an ordered collection of
java.lang.String values.
| Field Summary | |
|---|---|
protected OrderedCollection |
collection
The actual data structure that holds the data |
static java.lang.String |
RB_KEY
|
| Fields inherited from class com.sas.collection.BaseCollection |
|---|
allContentsChangedListeners, mappingObject |
| Constructor Summary | |
|---|---|
StringCollection()
Default constructor. |
|
StringCollection(int initialCapacity)
A constructor that allows the user to specify the initial capacity. |
|
StringCollection(StaticStringListInterface strings)
Construct a StringCollection that is populated with another collection of Strings. |
|
StringCollection(java.lang.String source)
Construct a new StringCollection from comma separated text. |
|
StringCollection(java.lang.String[] strings)
Construct a StringCollection that is populated with an array of Strings. |
|
StringCollection(java.lang.String source,
char separator)
Constructor that takes a String and a separator character and converts the String into a list of Strings. |
|
| Method Summary | |
|---|---|
void |
add(java.lang.Object item)
Add a String to this collection. |
void |
add(java.lang.Object item,
int index)
Add a String at a specific location in this collection. |
void |
add(java.lang.String item)
Add a string to this collection. |
void |
add(java.lang.String item,
int index)
Add an item to this collection at a specific location. |
void |
addItems(java.util.Enumeration items)
Add all elements of an enumeration to this collection. |
void |
addItems(java.util.Enumeration items,
int index)
Add multiple strings to this collection. |
void |
addItems(StaticStringListInterface items)
Add multiple strings to this collection. |
void |
append(int index,
java.lang.Object item)
Store a string to this collection, or append it if necessary. |
void |
append(int index,
java.lang.String string)
Store a string to this collection, or append it if necessary. |
void |
apply(com.sas.util.ApplyInterface action)
Applies the action action to every item in the current collection. |
java.lang.Object |
clone()
Clone the StringCollection |
boolean |
contains(java.lang.Object element)
Test for the existence of a String in this collection |
void |
contentsChanged(com.sas.collection.ContentsChangedEvent event)
Handle a ContentsChangedEvent. |
int |
count()
Returns the number of strings in this collection |
boolean |
equals(java.lang.Object obj)
Test for equality. |
boolean |
equals(StaticOrderedCollectionInterface orderedCollection)
Test if this collection equals another string collection by comparing elements in order. |
boolean |
equals(StaticStringListInterface list)
Test if this collection equals another string collection by comparing elements in order. |
java.lang.Object |
get(int index)
Fetch a String at an index. |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
|
int |
getIndex(java.lang.Object element,
int startIndex)
Returns the index associated with the String (searches forward) |
int |
getIndex(java.lang.String item,
int startIndex)
Returns the index associated with the string (searches forward) |
java.util.Enumeration |
getItems()
Return an Enumeration of all the strings. |
java.util.Enumeration |
getItems(int start,
int end)
Returns an enumeration of the strings from this collection. |
int |
getLastIndex(java.lang.Object element,
int startIndex)
Returns the last index associated with the string (searches backward) |
int |
getLastIndex(java.lang.String string,
int startIndex)
Returns the last index associated with the string (searches backward) |
java.lang.String |
getString(int index)
Fetch a string at an index. |
java.lang.String[] |
getStringItems()
Return the strings in this collection as an array of strings. |
StaticStringListInterface |
getStringItems(int start,
int end)
Extract a sublist of strings from this collection. |
boolean |
remove(java.lang.Object string)
Remove a string from this collection. |
void |
removeAll()
Remove all strings from this collection. |
int |
removeAll(java.lang.Object element)
Remove all occurrences of a string from this collection. |
java.lang.Object |
removeAt(int index)
Remove from this collection the string at the specified index. |
void |
removeAt(int start,
int n)
Delete multiple strings starting at a specified index. |
java.lang.String |
removeStringAt(int index)
Delete a string at a specified index. |
void |
set(int index,
java.lang.Object item)
Replace the item at the specified index with a new item. |
void |
setSize(int newSize)
Set the number of items that are being held in this collection. |
void |
setString(int index,
java.lang.String item)
Replace the string at the specified index with a new string |
void |
sort(boolean ascending)
Sorts the current collection in place in ascending/descending order using the built-in String comparator. |
void |
sort(boolean ascending,
int start,
int end)
Sorts the current collection in place in ascending/descending order using the built-in String comparison functions. |
void |
sort(com.sas.util.Comparator comparator)
Sorts the current collection in place using the provided comparison function. |
void |
sort(com.sas.util.Comparator comparator,
int start,
int end)
Sorts the current collection in place using the provided comparison function. |
java.lang.String |
toString()
Convert the string collection to a single string. |
java.lang.String |
toString(char delimiter,
boolean alwaysQuote)
Convert the string collection to a single string. |
java.lang.String[] |
toStringArray()
Return the Strings in this collection as an array of Strings. |
| Methods inherited from class com.sas.collection.BaseCollection |
|---|
addContentsChangedListener, anyContentsChangedListeners, disableEvents, enableEvents, enableEvents, fireContentsChanged, map, removeContentsChangedListener, unmap |
| Methods inherited from interface com.sas.collection.ContentsChangedSource |
|---|
addContentsChangedListener, removeContentsChangedListener |
| Methods inherited from interface com.sas.beans.PropertyChangeSource |
|---|
addPropertyChangeListener, removePropertyChangeListener |
| Field Detail |
|---|
public static final java.lang.String RB_KEY
protected OrderedCollection collection
| Constructor Detail |
|---|
public StringCollection()
public StringCollection(java.lang.String source)
source - a string of comma separated items.
This invokes the StringCollection(String, ',')
constructor.
public StringCollection(java.lang.String source,
char separator)
source - The String to be broken up.
Leading and trailing space is trimmed from each item. Items may be quoted but
it is necessary only if the item contains the separator or double
quotes, Unicode, octal, or other escaped characters.separator - The character to be used as a separator.public StringCollection(int initialCapacity)
initialCapacity - The initial capacity of the list.public StringCollection(StaticStringListInterface strings)
strings - a collection of strings.public StringCollection(java.lang.String[] strings)
strings - an array of String with which to initialize the StringCollection| Method Detail |
|---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
public void add(java.lang.String item,
int index)
add in interface StringListInterfaceitem - The item to insert into this collectionindex - The index where the item will be inserted. A call
of getString(index) will return the item after the call is completed.
java.lang.IndexOutOfBoundsException - if index
is not in the range [0..count()]
public void append(int index,
java.lang.Object item)
item - The Object to be added to the StringCollection;
it must be null or a String.
java.lang.ClassCastException - if item is not a String
public void append(int index,
java.lang.String string)
first. Then perform a
set(index, string).
- Parameters:
string - The string to be added to the StringCollection
public void contentsChanged(com.sas.collection.ContentsChangedEvent event)
contentsChanged in interface com.sas.collection.ContentsChangedListenerevent - a ContentsChangedEventpublic void add(java.lang.String item)
add in interface StringListInterfaceitem - a string to add to the end of this list.public void addItems(StaticStringListInterface items)
addItems in interface StringListInterfaceitems - a list of strings to add to the end of this list.public void addItems(java.util.Enumeration items)
addItems in interface CollectionInterfaceitems - an Enumeration of strings to add to the end of this collection
java.lang.ClassCastException - if the enumeration
contains non-String items.
public void addItems(java.util.Enumeration items,
int index)
addItems in interface OrderedCollectionInterfaceindex - Insert the objects starting before the indexed item. The
first of the newly inserted item can be accessed by get(index)
afterwards.items - an Enumeration of strings to add to this collection at the index.
java.lang.ClassCastException - if the enumeration
contains non-String items.public void add(java.lang.Object item)
add in interface CollectionInterfaceitem - a String to add to this collection
java.lang.ClassCastException - is thrown
if item is non-null and not a String.
public void add(java.lang.Object item,
int index)
add in interface OrderedCollectionInterfaceitem - the string to add to this collection.
The string may exist multiple times in this collection.Insert - the string before the indexed item. The
newly inserted string can be accessed by get(index) afterwards.
java.lang.IndexOutOfBoundsException - if index
is not in the range [0, count()].
java.lang.ClassCastException - This is thrown
if the caller tries to insert a non-String.public void apply(com.sas.util.ApplyInterface action)
apply in interface StaticCollectionInterfaceapply in class BaseCollectionaction - An object which operates on another object.public void removeAll()
removeAll in interface CollectionInterfaceremoveAll in interface StringListInterfacepublic boolean contains(java.lang.Object element)
contains in interface StaticCollectionInterfacecontains in class BaseCollectionelement - the string to search for
true if and only the string exists in this collection.
java.lang.ClassCastException - This is thrown
if the caller tries to insert a non-String.StaticCollectionInterface.contains(java.lang.Object)public int count()
count in interface com.sas.util.Countablecount in class BaseCollectionpublic boolean equals(StaticStringListInterface list)
equals in interface StaticStringListInterfacelist - Another string collection to be compared to.
true if equal, false otherwise.public boolean equals(StaticOrderedCollectionInterface orderedCollection)
equals in interface StaticOrderedCollectionInterfaceorderedCollection - Another ordered collection to be compared to.
true if equal, false otherwise.public boolean equals(java.lang.Object obj)
equals(StaticStringListInterface) or
equals(StaticOrderedCollectionInterface), respoectively.
If obj is neither of these interfaces, return false.
equals in class java.lang.Objectobj - an object to compare to.
true if equal, false otherwise.public java.lang.Object get(int index)
get in interface IndexedGetInterfaceindex - the position of the item, zero-based indexing.
java.lang.IndexOutOfBoundsException - if index
is not in the range [0, count()-1].
public int getIndex(java.lang.String item,
int startIndex)
getIndex in interface StaticStringListInterfaceitem - string to search forstartIndex - index where search should start
java.lang.IndexOutOfBoundsException - if startIndex
is not in the range [0..count()-1]
public int getIndex(java.lang.Object element,
int startIndex)
getIndex in interface StaticOrderedCollectionInterfaceelement - string to search forstartIndex - the position where the search should start
java.lang.IndexOutOfBoundsException - if startIndex is
not valid.
java.lang.ClassCastException - if the caller tries to insert a non-String.
public StaticStringListInterface getStringItems(int start,
int end)
getStringItems in interface StaticStringListInterfacestart - the index of the first string, zero based.end - one past the index of the last item to include in the sublist, zero based.
java.lang.IndexOutOfBoundsException - if start
is not in the range [0, count()-1].
or end is not in the range [0, count()].StaticOrderedCollectionInterface.getItems(int, int),
String.substring(int, int)public java.lang.String[] getStringItems()
getStringItems in interface StaticStringListInterfacepublic final java.lang.String[] toStringArray()
getStringItems()
public java.util.Enumeration getItems()
Enumeration of all the strings.
getItems in interface com.sas.util.EnumerablegetItems in class BaseCollectionEnumeration of this collection's elementsEnumerable.getItems()
public java.util.Enumeration getItems(int start,
int end)
getItems in interface StaticOrderedCollectionInterfacestart - the index of the first string, zero based.end - one past the index of the last item to include in the enumeration, zero based.
Note that the range of elements returned in the Enumeration does not
include the endthe item; this is consistent with substring(start, end), for example.
Enumeration of the strings.
java.lang.IndexOutOfBoundsException - if start
is not in the range [0, count()-1],
or if end is not in the range [0, count()]
public int getLastIndex(java.lang.String string,
int startIndex)
getLastIndex in interface StaticStringListInterfacestring - the string to search forstartIndex - index where search should start
java.lang.IndexOutOfBoundsException - if the start index
is not in the range [0..count()-1]
public int getLastIndex(java.lang.Object element,
int startIndex)
getLastIndex in interface StaticOrderedCollectionInterfaceelement - the string to search forstartIndex - the position where the search should start
java.lang.IndexOutOfBoundsException - if startIndex is
not valid.public java.lang.String getString(int index)
getString in interface StaticStringListInterfacethe - position of the string, zero based indexing.
java.lang.IndexOutOfBoundsException - if index
is not in the range [0, count()-1].public boolean remove(java.lang.Object string)
remove in interface CollectionInterfacestring - the string to remove
true if the string was removed, false if not.public int removeAll(java.lang.Object element)
removeAll in interface CollectionInterfaceelement - the item to remove
public void removeAt(int start,
int n)
removeAt in interface StringListInterfacestart - position of first string to deleten - number of strings to delete from this collection
java.lang.IndexOutOfBoundsException - if start
or (start+n-1) are not in the range [0..count()-1]public java.lang.Object removeAt(int index)
removeAt in interface OrderedCollectionInterfaceindex - the position of the string, zero-based indexing.
java.lang.IndexOutOfBoundsException - if index
is not in the range [0, count()-1].public java.lang.String removeStringAt(int index)
removeStringAt in interface StringListInterfaceindex - delete the string at this zero-based position
java.lang.IndexOutOfBoundsException - if the index
is not in the range [0..count()-1]StringListInterface.removeAt(int, int)
public void set(int index,
java.lang.Object item)
set in interface OrderedCollectionInterfaceset in interface IndexedSetInterfaceindex - The position where the item will be placed.item - The object to be added to this Collection
java.lang.IndexOutOfBoundsException - if index
is not in the range [0, count()-1].
java.lang.ClassCastException - This is thrown
if item is not a String.
public void setString(int index,
java.lang.String item)
setString in interface StringListInterfaceindex - position of the string to replaceitem - The new string to put in the specified location
java.lang.IndexOutOfBoundsException - if index
is not in the range [0..count()-1]public void setSize(int newSize)
null.
setSize in interface OrderedCollectionInterfacesetSize in interface StringListInterfacesize - The new size of this collection
java.lang.IndexOutOfBoundsException - if newSize is less than zero.
public void sort(com.sas.util.Comparator comparator,
int start,
int end)
sort in interface Sortablesort in interface StringListInterfacecomparator - An instance of a Comparator which providess a
Comparator.compare(Object, Object) function.start - the index of the first item in the range to sortend - sort the items between start and (end-1)Comparatorpublic void sort(com.sas.util.Comparator comparator)
sort in interface Sortablesort in interface StringListInterfacecomparator - An instance of a Comparator which provides a
Comparator.compare(Object, Object) function.Comparatorpublic void sort(boolean ascending)
sort in interface StringListInterfaceascending - If true, sort this collection in ascending order; otherwise
descending order.StringComparator
public void sort(boolean ascending,
int start,
int end)
sort in interface StringListInterfaceascending - If true, sort this collection in ascending order; otherwise
descending order.start - the index of the first item in the range to sortend - sort the items between start and (end-1)StringComparatorpublic java.lang.String toString()
toString(',', true).
toString in class java.lang.Object
public java.lang.String toString(char delimiter,
boolean alwaysQuote)
delimiter - a delimiter for separating the items.alwaysQuote - if true, all items are quoted. If false, only
quote items which require quotes (such as strings containing
the delimiter character, or the '\' character, etc.)
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in interface CollectionInterfaceclone in interface OrderedCollectionInterfaceclone in interface StaticCollectionInterfaceclone in interface StaticOrderedCollectionInterfaceclone in interface StaticStringListInterfaceclone in interface StringListInterfaceclone in interface com.sas.PublicClonableclone in class BaseCollectionjava.lang.CloneNotSupportedException - if
this collection cannot be cloned.
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||