public class CollectionsX
extends java.lang.Object
Collections
Modifier and Type | Class and Description |
---|---|
static class |
CollectionsX.ArrayCollection<E>
An readonly collection on top of an array.
|
static class |
CollectionsX.ArrayEnumeration<E>
An enumeration on top of an array.
|
static class |
CollectionsX.ArrayIterator<E>
An iterator on top of an array.
|
static class |
CollectionsX.ArrayList<E>
An readonly list on top of an array.
|
static class |
CollectionsX.ArrayListIterator<E> |
static class |
CollectionsX.CollectionEnumeration<E>
An enumeration on top of a collection or iterator.
|
static class |
CollectionsX.EnumerationIterator<E>
An iterator that iterates thru an Enumeration.
|
static class |
CollectionsX.OneCollection<E>
A collection that contains only one element.
|
static class |
CollectionsX.OneEnumeration<E>
An enumeration that enumerates one element.
|
static class |
CollectionsX.OneIterator<E>
An iterator that iterates one element.
|
Modifier and Type | Field and Description |
---|---|
static java.util.Enumeration |
EMPTY_ENUMERATION
Empty enumeration.
|
static java.util.Iterator |
EMPTY_ITERATOR
Empty iterator.
|
Constructor and Description |
---|
CollectionsX() |
Modifier and Type | Method and Description |
---|---|
static <T> int |
addAll(java.util.Collection<T> col,
java.util.Enumeration<? extends T> enm)
Adds all elements returned by the enumerator to a collection.
|
static <T> int |
addAll(java.util.Collection<T> col,
java.util.Iterator<? extends T> iter)
Adds all elements returned by the iterator to a collection.
|
static <T> int |
addAll(java.util.Collection<T> col,
java.lang.Object[] ary)
Adds all elements of an array to a collection.
|
static <E> java.util.Iterator<E> |
comodifiableIterator(java.util.Collection<E> col)
Returns an iterator that allows the caller to modify the collection
directly (in addition to Iterator.remove()).
|
static <F,T> java.util.Iterator<T> |
comodifiableIterator(java.util.Collection<F> col,
Converter<F,T> converter)
Returns an iterator that allows the caller to modify the collection
directly (in addition to Iterator.remove()).
|
static <T> java.util.Enumeration<T> |
emptyEnumeration()
Returns a generic empty enumeration.
|
static <T> java.lang.Iterable<T> |
emptyIterable()
Returns an empty iterable object.
|
static <T> java.util.Iterator<T> |
emptyIterator()
Returns a generic empty iterator.
|
static boolean |
isIntersected(java.util.Set<?> a,
java.util.Set<?> b)
Tests whether two sets has any intersection.
|
static java.util.Iterator |
iterator(java.lang.Object obj)
Based on the given collection type of Object, return an iterator.
|
static java.util.Collection<java.lang.String> |
parse(java.util.Collection<java.lang.String> c,
java.lang.String src,
char separator)
Parses a string into a list.
|
static java.util.Collection<java.lang.String> |
parse(java.util.Collection<java.lang.String> c,
java.lang.String src,
char separator,
boolean escBackslash)
Parses a string into a list.
|
static java.util.Collection<java.lang.String> |
parse(java.util.Collection<java.lang.String> c,
java.lang.String src,
char separator,
boolean escBackslash,
boolean parenthesis)
Parses a string into a list.
|
static <T> T[] |
toArray(java.util.Collection<? extends T> col,
T[] dst,
int from,
int to)
Returns the specified range of the given collection;
the runtime type of the returned array is that of the specified array.
|
static java.lang.Object[] |
toArray(java.util.Collection col,
int from,
int to)
Returns the specified range of the specified collection into a new array.
|
public static final java.util.Iterator EMPTY_ITERATOR
public static final java.util.Enumeration EMPTY_ENUMERATION
public static final <T> java.util.Iterator<T> emptyIterator()
public static final <T> java.util.Enumeration<T> emptyEnumeration()
public static final <T> java.lang.Iterable<T> emptyIterable()
public static final java.lang.Object[] toArray(java.util.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 <T> T[] toArray(java.util.Collection<? extends T> col, T[] dst, int from, int to)
col
- the collection to be copied.dst
- the array into which the elements of this list are to be stored,
if it is big enough (less than to - from
; otherwise, a new array of the same runtime type is allocated for this purpose.
Note: dst[0] will be col[from].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 <T> int addAll(java.util.Collection<T> col, java.util.Iterator<? extends T> iter)
iter
- the iterator; null is OKpublic static final <T> int addAll(java.util.Collection<T> col, java.util.Enumeration<? extends T> enm)
enm
- the enumeration; null is OKpublic static final <T> int addAll(java.util.Collection<T> col, java.lang.Object[] ary)
ary
- the array; null is OKpublic static final boolean isIntersected(java.util.Set<?> a, java.util.Set<?> b)
public static final java.util.Collection<java.lang.String> parse(java.util.Collection<java.lang.String> c, java.lang.String src, char separator)
parse(Collection, String, char, boolean, boolean)
for details.public static final java.util.Collection<java.lang.String> parse(java.util.Collection<java.lang.String> c, java.lang.String src, char separator, boolean escBackslash)
parse(Collection, String, char, boolean, boolean)
for details.public static final java.util.Collection<java.lang.String> parse(java.util.Collection<java.lang.String> c, java.lang.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<? super java.lang.String, ? super java.lang.String>, java.lang.String, char, char)
public static final java.util.Iterator iterator(java.lang.Object obj)
public static <E> java.util.Iterator<E> comodifiableIterator(java.util.Collection<E> col)
Limitation:
for (Iterator it = org.zkoss.util.CollectionsX.comodifiableIterator(list); it.hasNext();) {
it.next();
l.remove(0);
}
public static <F,T> java.util.Iterator<T> comodifiableIterator(java.util.Collection<F> col, Converter<F,T> converter)
converter
- the filter used to convert the value of each element
found in the given collection to the return iterator.
Ignored if null (and then F must be the same as T or extends from T).Copyright © 2005-2021 Potix Corporation. All Rights Reserved.