|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.util.CollectionsX
public class CollectionsX
The collection related utilities.
Collections| Nested Class Summary | |
|---|---|
static class |
CollectionsX.ArrayCollection
An readonly collection on top of an array. |
static class |
CollectionsX.ArrayEnumeration
An enumeration on top of an array. |
static class |
CollectionsX.ArrayIterator
An iterator on top of an array. |
static class |
CollectionsX.ArrayList
An readonly list on top of an array. |
static class |
CollectionsX.ArrayListIterator
|
static class |
CollectionsX.CollectionEnumeration
An enumeration on top of a collection or iterator. |
static class |
CollectionsX.EnumerationIterator
An iterator that iterates thru an Enumeration. |
static class |
CollectionsX.OneCollection
A collection that contains only one element. |
static class |
CollectionsX.OneEnumeration
An enumeration that enumerates one element. |
static class |
CollectionsX.OneIterator
An iterator that iterates one element. |
| Field Summary | |
|---|---|
static Enumeration |
EMPTY_ENUMERATION
Empty enumeration. |
static Iterator |
EMPTY_ITERATOR
Empty iterator. |
| Constructor Summary | |
|---|---|
CollectionsX()
|
|
| Method Summary | |
|---|---|
static int |
addAll(Collection col,
Enumeration enm)
Adds all elements returned by the enumerator to a collection. |
static int |
addAll(Collection col,
Iterator iter)
Adds all elements returned by the iterator to a collection. |
static int |
addAll(Collection col,
Object[] ary)
Adds all elements of an array to a collection. |
static Iterator |
comodifiableIterator(Collection col)
Returns an iterator that allows the caller to modify the collection directly (in addition to Iterator.remove()). |
static boolean |
isIntersected(Set a,
Set b)
Tests whether two sets has any intersection. |
static Iterator |
iterator(Object obj)
Based on the given collection type of Object, return an iterator. |
static Collection |
parse(Collection c,
String src,
char separator)
Parses a string into a list. |
static Collection |
parse(Collection c,
String src,
char separator,
boolean escBackslash)
Parses a string into a list. |
static Collection |
parse(Collection c,
String src,
char separator,
boolean escBackslash,
boolean parenthesis)
Parses a string into a list. |
static Object[] |
toArray(Collection col,
int from,
int to)
Returns the specified range of the specified collection into a new array. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Iterator EMPTY_ITERATOR
public static final Enumeration EMPTY_ENUMERATION
| Constructor Detail |
|---|
public CollectionsX()
| Method Detail |
|---|
public static final Object[] toArray(Collection col,
int from,
int to)
The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array.
This method acts as bridge between array-based and collection-based APIs.
col - the collection to be copied.from - the initial index of the range to be copied, inclusive.to - the final index of the range to be copied, exclusive.
public static final int addAll(Collection col,
Iterator iter)
iter - the iterator; null is OK
public static final int addAll(Collection col,
Enumeration enm)
enm - the enumeration; null is OK
public static final int addAll(Collection col,
Object[] ary)
ary - the array; null is OK
public static final boolean isIntersected(Set a,
Set b)
public static final Collection parse(Collection c,
String src,
char separator)
parse(Collection, String, char, boolean, boolean)
for details.
IllegalSyntaxException - if syntax errorsMaps.parse(java.util.Map, java.lang.String, char, char),
parse(Collection, String, char, boolean, boolean)
public static final Collection parse(Collection c,
String src,
char separator,
boolean escBackslash)
parse(Collection, String, char, boolean, boolean)
for details.
IllegalSyntaxException - if syntax errorsMaps.parse(java.util.Map, java.lang.String, char, char),
parse(Collection, String, char, boolean, boolean)
public static final Collection parse(Collection c,
String src,
char separator,
boolean escBackslash,
boolean parenthesis)
Unlike Java, quotation could spread over multiple lines.
Example,
a b , ' c d',"'f'", '1' "2", 3
generate a list of "a b", "c d", "'f'", "1", "2" and "3".
Note: the separator between "1" and "2" is optional.
Note: Like Java, if the string is ending with a separator, it will be ignored.
Example,
a, , b,
generate a list of "a", "", "b".
c - the collection to hold the parsed results; a linked list
is created if c is null.src - the string to parseseparator - the separator, e.g., ',', '\n' or ' '.
Note: if separator is ' ', it denotes any white space.escBackslash - whether to treat '\\' specially (as escape char)parenthesis - whether to parse parenthesis in the value, {}, () and [].
If true, the separator is ignored inside the parenthesis.
Specify true if the value might contain EL expressions.
c collection if not null; or a linked list
if c is null (so you can cast it to List)
IllegalSyntaxException - if syntax errorsMaps.parse(java.util.Map, java.lang.String, char, char)public static final Iterator iterator(Object obj)
public static Iterator comodifiableIterator(Collection col)
Limitation:
for (Iterator it = org.zkoss.util.CollectionsX.comodifiableIterator(list); it.hasNext();) {
it.next();
l.remove(0);
}
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||