|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.pf.util.CollectionUtil
public class CollectionUtil
This class implements the singleton pattern. Access the sole instance with the method current(). Provides helpful functions on collections.
| Field Summary | |
|---|---|
static java.util.List |
EMPTY_LIST
A constant that contains an immutable empty List. |
static java.util.Map |
EMPTY_MAP
A constant that contains an immutable empty Map. |
static java.util.Set |
EMPTY_SET
A constant that contains an immutable empty Set. |
| Method Summary | |
|---|---|
void |
addAll(java.util.Collection collection,
java.lang.Object[] objects)
Adds all given objects to the specified collection. |
void |
addAllNew(java.util.Collection collection,
java.lang.Object[] objects)
Adds all given objects to the specified collection, if they are not already in the collection. |
java.util.Iterator |
asIterator(java.util.Enumeration enumeration)
Returns an iterator based on the given enumeration or null if the input parameter is null, too. |
java.util.List |
asList(java.util.Enumeration enumeration)
Returns a list containing all elements of the given enumeration. |
boolean |
contains(int[] valueArray,
int value)
Returns true only if the given value is found in the given array. |
boolean |
contains(long[] valueArray,
long value)
Returns true only if the given value is found in the given array. |
boolean |
contains(java.lang.Object[] objArray,
java.lang.Object searchObj)
Returns true if the search object exists in the given object array. |
boolean |
containsIdentical(java.lang.Object[] objArray,
java.lang.Object searchObj)
Returns true if the search object exists in the given object array. |
java.util.Collection |
copy(java.util.Collection objects,
IObjectFilter filter)
Returns a copy of the given collection which contains only those objects that match the given filter. |
java.util.Map |
copy(java.util.Map map,
IObjectFilter filter)
Returns a copy of the given map which contains only those objects that match the given filter. |
java.lang.Object[] |
copy(java.lang.Object[] objects)
Returns a copy of the given object array. |
java.lang.Object[] |
copy(java.lang.Object[] objects,
IObjectFilter filter)
Returns a copy of the given object array which contains only those objects that match the given filter. |
void |
copyPropertiesStartingWith(java.util.Properties source,
java.util.Properties destination,
java.lang.String prefix,
boolean cutPrefix)
Copies all properties that start with the given prefix from the specified source properties object to the destination properties. |
java.util.Collection |
copyWithout(java.util.Collection objects,
IObjectFilter filter)
Returns a copy of the specified collection that contains only those elements that do NOT match the given filter. |
java.util.Map |
copyWithout(java.util.Map map,
IObjectFilter filter)
Returns a copy of the specified map that contains only those elements that do NOT match the given filter. |
java.lang.Object[] |
copyWithout(java.lang.Object[] objArray,
IObjectFilter filter)
Returns a copy of the specified array that contains only those elements that do NOT match the given filter. |
java.lang.Object[] |
copyWithout(java.lang.Object[] objArray,
java.lang.Object[] skipArray)
Returns a copy of the first array that contains only elements that are not in the second array. |
java.lang.Object[] |
copyWithoutIdentical(java.lang.Object[] objArray,
java.lang.Object[] skipArray)
Returns a copy of the first array that contains only elements that are not in the second array. |
static CollectionUtil |
current()
Returns the one and only instance of this class. |
int |
indexOf(java.util.List list,
IObjectFilter filter)
Returns the index of the first object in the given list that matches the given filter. |
int |
indexOf(java.lang.Object[] objArray,
IObjectFilter filter)
Returns the index of the first object in the given object array that matches the given filter. |
int |
indexOf(java.lang.Object[] objArray,
java.lang.Object searchObj)
Returns the index of the search object in the given object array. |
int |
indexOfIdentical(java.lang.Object[] objArray,
java.lang.Object searchObj)
Returns the index of the search object in the given object array. |
boolean |
isNullOrEmpty(AssociationList associationList)
Returns true if the given association list is null or has no elements. |
boolean |
isNullOrEmpty(java.util.Collection collection)
Returns true if the given collection is null or has no elements. |
boolean |
isNullOrEmpty(java.util.Map map)
Returns true if the given map is null or has no elements. |
boolean |
isNullOrEmpty(java.lang.Object[] array)
Returns true if the given array is null or has no elements. |
java.util.Iterator |
iterator(java.lang.Object[] objects)
Returns an iterator on the given array. |
int |
lastIndexOf(java.util.List list,
IObjectFilter filter)
Returns the index of the last object in the given list that matches the given filter. |
int |
lastIndexOf(java.lang.Object[] objArray,
IObjectFilter filter)
Returns the index of the last object in the given object array that matches the given filter. |
java.util.Properties |
propertiesStartingWith(java.util.Properties source,
java.lang.String prefix)
Returns a new properties object with all properties that start with the given prefix copied from the specified source properties object. |
java.util.Properties |
propertiesStartingWith(java.util.Properties source,
java.lang.String prefix,
boolean cutPrefix)
Returns a new properties object with all properties that start with the given prefix copied from the specified source properties object. |
java.lang.Object[] |
removeNull(java.lang.Object[] array)
Removes all null values from the given array. |
void |
reverse(java.lang.Object[] array)
Puts all elements in the specified array into reverse order. |
java.lang.Object[] |
reverseCopy(java.lang.Object[] array)
Returns a new array that contains all elements of the given array in reverse order. |
java.lang.Object[] |
toArray(java.util.Collection objects)
Returns an which has elements of the type of the first element in the given collection. |
java.lang.Object[] |
toArray(java.util.Collection objects,
java.lang.Class elementType)
Returns an array which has elements of the specified element type. |
java.util.List |
toList(java.lang.Object[] objects)
Returns an ArrayList that contains all objects from the given array. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.util.Set EMPTY_SET
public static final java.util.List EMPTY_LIST
public static final java.util.Map EMPTY_MAP
| Method Detail |
|---|
public static CollectionUtil current()
public java.util.Properties propertiesStartingWith(java.util.Properties source,
java.lang.String prefix)
source - The properties to copy fromprefix - The prefix all properties to copy have in common
public java.util.Properties propertiesStartingWith(java.util.Properties source,
java.lang.String prefix,
boolean cutPrefix)
source - The properties to copy fromprefix - The prefix all properties to copy have in commoncutPrefix - If true, the prefix gets cut off the keys in the destination object
public void copyPropertiesStartingWith(java.util.Properties source,
java.util.Properties destination,
java.lang.String prefix,
boolean cutPrefix)
source - The properties to copy from (if null nothing happens at all)destination - The destination object where the properties are copied to (if null nothing happens at all)prefix - The prefix all properties to copy have in common (if null nothing happens at all)cutPrefix - If true, the prefix gets cut off the keys in the destination objectpublic java.lang.Object[] copy(java.lang.Object[] objects)
public java.lang.Object[] copy(java.lang.Object[] objects,
IObjectFilter filter)
public java.util.Collection copy(java.util.Collection objects,
IObjectFilter filter)
public java.util.Map copy(java.util.Map map,
IObjectFilter filter)
public java.lang.Object[] reverseCopy(java.lang.Object[] array)
public void reverse(java.lang.Object[] array)
public void addAll(java.util.Collection collection,
java.lang.Object[] objects)
collection - The collection to which the objects are addedobjects - The objects to add to the collection
public void addAllNew(java.util.Collection collection,
java.lang.Object[] objects)
collection - The collection to which the objects are addedobjects - The objects to add to the collection
public int indexOfIdentical(java.lang.Object[] objArray,
java.lang.Object searchObj)
objArray - The array to search insearchObj - The object to search for (might be null)
public int indexOf(java.lang.Object[] objArray,
java.lang.Object searchObj)
objArray - The array to search insearchObj - The object to search for (might be null)
public int indexOf(java.lang.Object[] objArray,
IObjectFilter filter)
objArray - The array to search infilter - The filter to determine the object to look for (must not be null)
public int lastIndexOf(java.lang.Object[] objArray,
IObjectFilter filter)
objArray - The array to search infilter - The filter to determine the object to look for (must not be null)
public int indexOf(java.util.List list,
IObjectFilter filter)
list - The list to search infilter - The filter to determine the object to look for (must not be null)
public int lastIndexOf(java.util.List list,
IObjectFilter filter)
list - The list to search infilter - The filter to determine the object to look for (must not be null)
public boolean containsIdentical(java.lang.Object[] objArray,
java.lang.Object searchObj)
objArray - The array to search insearchObj - The object to search for (might be null)
public boolean contains(java.lang.Object[] objArray,
java.lang.Object searchObj)
objArray - The array to search insearchObj - The object to search for (might be null)
public boolean contains(int[] valueArray,
int value)
valueArray - The array in which to look for the valuevalue - The value to look for
public boolean contains(long[] valueArray,
long value)
valueArray - The array in which to look for the valuevalue - The value to look for
public java.lang.Object[] copyWithoutIdentical(java.lang.Object[] objArray,
java.lang.Object[] skipArray)
objArray - The array to take the elements fromskipArray - The array that contains all objects that must not be in the result array
public java.lang.Object[] copyWithout(java.lang.Object[] objArray,
java.lang.Object[] skipArray)
objArray - The array to take the elements fromskipArray - The array that contains all objects that must not be in the result array
public java.lang.Object[] copyWithout(java.lang.Object[] objArray,
IObjectFilter filter)
objArray - The array to take the elements fromfilter - A filter that defines all elements must not be copied into the result array
public java.util.Collection copyWithout(java.util.Collection objects,
IObjectFilter filter)
objects - The collection to take the elements fromfilter - A filter that defines all elements must not be copied into the result collection
public java.util.Map copyWithout(java.util.Map map,
IObjectFilter filter)
map - The map to take the elements fromfilter - A filter that defines all elements must not be copied into the result mappublic java.util.Iterator iterator(java.lang.Object[] objects)
objects - The objects to provide an interator forpublic java.lang.Object[] removeNull(java.lang.Object[] array)
array - The array to be cleared of null values
public java.lang.Object[] toArray(java.util.Collection objects,
java.lang.Class elementType)
objects - The object to be put into the result arrayelementType - The type of the array elements
java.lang.ArrayStoreException - if any element in the collection is not of the same type as the element typepublic java.lang.Object[] toArray(java.util.Collection objects)
java.lang.ArrayStoreException - if any element in the collection is not of the same type as the first elementpublic java.util.List toList(java.lang.Object[] objects)
public boolean isNullOrEmpty(java.util.Collection collection)
collection - The collection to checkpublic boolean isNullOrEmpty(java.lang.Object[] array)
array - The array to checkpublic boolean isNullOrEmpty(java.util.Map map)
map - The map to checkpublic boolean isNullOrEmpty(AssociationList associationList)
associationList - The association list to checkpublic java.util.Iterator asIterator(java.util.Enumeration enumeration)
public java.util.List asList(java.util.Enumeration enumeration)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||