|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.myfaces.trinidad.util.CollectionUtils
public final class CollectionUtils
This class contains Collection utilities.
Nested Class Summary | |
---|---|
protected static class |
CollectionUtils.DelegatingCollection<E>
|
protected static class |
CollectionUtils.DelegatingEntry<K,V>
|
protected static class |
CollectionUtils.DelegatingMap<K,V>
|
Method Summary | ||
---|---|---|
static
|
arrayList(java.util.Iterator<T> iterator)
Returns an ArrayList containing all of the elements of the Iterator |
|
protected static
|
copyOf(T[] original,
int newLength)
|
|
protected static
|
copyOf(U[] original,
int newLength,
java.lang.Class<? extends T[]> newType)
|
|
static
|
emptyIterator()
Returns an empty, unmodifiable, Iterator. |
|
static
|
emptyListIterator()
Returns an empty, unmodifiable, ListIterator. |
|
static
|
emptyQueue()
Returns an empty, unmodifiable, Serializable Queue. |
|
static
|
getCheckedSerializationMap(java.util.Map<K,V> map)
Creates a Map that dynamically verifies that all keys and values added to it will succeed Serialization. |
|
static
|
getSerializableCollection(java.util.Collection<T> c)
Returns a Collection based on the passed in Collection c ,
guaranteed to be Serializable. |
|
static
|
getSerializableList(java.util.List<T> l)
Returns a List based on the passed in List l ,
guaranteed to be Serializable. |
|
static
|
newSerializableList(java.util.List<T> l)
Returns a List based on the passed in List l ,
guaranteed to be Serializable. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> java.util.ArrayList<T> arrayList(java.util.Iterator<T> iterator)
iterator
- Iterator to copy the contexts of
public static <T> java.util.Queue<T> emptyQueue()
public static <T> java.util.Iterator<T> emptyIterator()
public static <T> java.util.ListIterator<T> emptyListIterator()
public static <T> java.util.Collection<T> getSerializableCollection(java.util.Collection<T> c)
c
,
guaranteed to be Serializable. If c
is Serializable,
c
will be returned, otherwise, c
will be
wrapped in a Collection that implements Serializable and upon
Serialization the contents of c
will be copied into
the result.
The results is very similar to creating a new ArrayList with the
contents of c
, but no wrapper is created unless necessary
and the actual creation of the Serializable copy is deferred until
Serialization occurs.
c
- The Collection to get a Serializable version of
c
getSerializableList(java.util.List)
public static <T> java.util.List<T> newSerializableList(java.util.List<T> l)
l
,
guaranteed to be Serializable. List l
will be
wrapped in a List that implements Serializable and upon
Serialization the contents of l
will be copied into
the result.
If l
implements RandomAccess, any returned List will also
implement RandomAccess.
The results is very similar to creating a new ArrayList with the
contents of l
, but no wrapper is created unless necessary
and the actual creation of the Serializable copy is deferred until
Serialization occurs.
Code that calls List.subList() and needs the result to be Serializable should always
use newSerializableList
rather than getSerializableList
because
the java.util.Collections
implementations of checkedList
,
unmodifiableList
, and synchronizedList
all lie and always implement
Serializable, regardless of the serializability of their backing List.
l
- The List to get a Serializable version of
l
getSerializableList(java.util.List)
,
getSerializableCollection(java.util.Collection)
public static <T> java.util.List<T> getSerializableList(java.util.List<T> l)
l
,
guaranteed to be Serializable. If l
is Serializable,
l
will be returned, otherwise, l
will be
wrapped in a List that implements Serializable and upon
Serialization the contents of l
will be copied into
the result.
If l
implements RandomAccess, any returned List will also
implement RandomAccess.
The results is very similar to creating a new ArrayList with the
contents of l
, but no wrapper is created unless necessary
and the actual creation of the Serializable copy is deferred until
Serialization occurs.
Code that calls List.subList() and needs the result to be Serializable should always
use newSerializableList
rather than getSerializableList
because
the java.util.Collections
implementations of checkedList
,
unmodifiableList
, and synchronizedList
all lie and always implement
Serializable, regardless of the serializability of their backing List.
l
- The List to get a Serializable version of
l
newSerializableList(java.util.List)
,
getSerializableCollection(java.util.Collection)
public static <K,V> java.util.Map<K,V> getCheckedSerializationMap(java.util.Map<K,V> map)
This checking can be defeated by either modifying the backing map directly or by modifying an object added to the checked Map after adding it.
map
- Map to wrap for Serialization validation
protected static <T> T[] copyOf(T[] original, int newLength)
protected static <T,U> T[] copyOf(U[] original, int newLength, java.lang.Class<? extends T[]> newType)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |