org.apache.commons.collections
クラス CollectionUtils

java.lang.Object
  |
  +--org.apache.commons.collections.CollectionUtils

public class CollectionUtils
extends java.lang.Object

A set of Collection related utility methods.

バージョン:
$Id: CollectionUtils.java,v 1.4 2001/05/22 15:53:06 jstrachan Exp $
作成者:
Rodney Waldhoff

コンストラクタの概要
CollectionUtils()
           
 
メソッドの概要
static void addAll(java.util.Collection collection, java.util.Enumeration enumeration)
          Adds all elements in the enumeration to the given collection
static void addAll(java.util.Collection collection, java.util.Iterator iterator)
          Adds all elements in the iteration to the given collection
static void addAll(java.util.Collection collection, java.lang.Object[] elements)
          Adds all elements in the array to the given collection
static int cardinality(java.lang.Object obj, java.util.Collection col)
          Returns the number of occurrences of obj in col.
static java.util.Collection collect(java.util.Collection inputCollection, Transformer transformer)
          Transforms all elements from inputCollection with the given transformer and adds them to the outputCollection
static java.util.Collection collect(java.util.Collection inputCollection, Transformer transformer, java.util.Collection outputCollection)
          Transforms all elements from inputCollection with the given transformer and adds them to the outputCollection
static java.util.Collection collect(java.util.Iterator inputIterator, Transformer transformer)
          Transforms all elements from the inputIterator with the given transformer and adds them to the outputCollection
static java.util.Collection collect(java.util.Iterator inputIterator, Transformer transformer, java.util.Collection outputCollection)
          Transforms all elements from the inputIterator with the given transformer and adds them to the outputCollection
static java.util.Collection disjunction(java.util.Collection a, java.util.Collection b)
          Returns a Collection containing the exclusive disjunction (symmetric difference) of the given Collections.
static java.lang.Object find(java.util.Collection collection, Predicate predicate)
          Finds the first element in the given collection which matches the given predicate
static void forAllDo(java.util.Collection collection, Closure closure)
          Executes the given closure on each element in the colleciton
static java.util.Map getCardinalityMap(java.util.Collection col)
          Returns a Map mapping each unique element in the given Collection to an Integer representing the number of occurances of that element in the Collection.
static java.util.Collection intersection(java.util.Collection a, java.util.Collection b)
          Returns a Collection containing the intersection of the given Collections.
static boolean isEqualCollection(java.util.Collection a, java.util.Collection b)
          Returns true iff the given Collections contain exactly the same elements with exactly the same cardinality.
static boolean isProperSubCollection(java.util.Collection a, java.util.Collection b)
          Returns true iff a is a proper sub-collection of b, that is, iff the cardinality of e in a is less than or equal to the cardinality of e in b, for each element e in a, and there is at least one element f such that the cardinality of f in b is strictly greater than the cardinality of f in a.
static boolean isSubCollection(java.util.Collection a, java.util.Collection b)
          Returns true iff a is a sub-collection of b, that is, iff the cardinality of e in a is less than or equal to the cardinality of e in b, for each element e in a.
static java.util.Collection select(java.util.Collection inputCollection, Predicate predicate)
          Selects all elements from inputCollection which match the given predicate into an output collection
static void select(java.util.Collection inputCollection, Predicate predicate, java.util.Collection outputCollection)
          Selects all elements from inputCollection which match the given predicate and adds them to outputCollection
static java.util.Collection subtract(java.util.Collection a, java.util.Collection b)
          Returns a Collection containing a - b.
static java.util.Collection union(java.util.Collection a, java.util.Collection b)
          Returns a Collection containing the union of the given Collections.
 
クラス java.lang.Object から継承したメソッド
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

CollectionUtils

public CollectionUtils()
メソッドの詳細

addAll

public static void addAll(java.util.Collection collection,
                          java.util.Enumeration enumeration)
Adds all elements in the enumeration to the given collection

addAll

public static void addAll(java.util.Collection collection,
                          java.util.Iterator iterator)
Adds all elements in the iteration to the given collection

addAll

public static void addAll(java.util.Collection collection,
                          java.lang.Object[] elements)
Adds all elements in the array to the given collection

cardinality

public static int cardinality(java.lang.Object obj,
                              java.util.Collection col)
Returns the number of occurrences of obj in col.

collect

public static java.util.Collection collect(java.util.Collection inputCollection,
                                           Transformer transformer)
Transforms all elements from inputCollection with the given transformer and adds them to the outputCollection

collect

public static java.util.Collection collect(java.util.Collection inputCollection,
                                           Transformer transformer,
                                           java.util.Collection outputCollection)
Transforms all elements from inputCollection with the given transformer and adds them to the outputCollection
戻り値:
the outputCollection

collect

public static java.util.Collection collect(java.util.Iterator inputIterator,
                                           Transformer transformer)
Transforms all elements from the inputIterator with the given transformer and adds them to the outputCollection

collect

public static java.util.Collection collect(java.util.Iterator inputIterator,
                                           Transformer transformer,
                                           java.util.Collection outputCollection)
Transforms all elements from the inputIterator with the given transformer and adds them to the outputCollection
戻り値:
the outputCollection

disjunction

public static java.util.Collection disjunction(java.util.Collection a,
                                               java.util.Collection b)
Returns a Collection containing the exclusive disjunction (symmetric difference) of the given Collections.

The cardinality of each element e in the returned Collection will be equal to max(cardinality(e,a),cardinality(e,b)) - min(cardinality(e,a),cardinality(e,b)).

This is equivalent to subtract(union(a,b),intersection(a,b)) or union(subtract(a,b),subtract(b,a)).


find

public static java.lang.Object find(java.util.Collection collection,
                                    Predicate predicate)
Finds the first element in the given collection which matches the given predicate
戻り値:
the first element of the collection which matches the predicate or null if none could be found

forAllDo

public static void forAllDo(java.util.Collection collection,
                            Closure closure)
Executes the given closure on each element in the colleciton

getCardinalityMap

public static java.util.Map getCardinalityMap(java.util.Collection col)
Returns a Map mapping each unique element in the given Collection to an Integer representing the number of occurances of that element in the Collection. An entry that maps to null indicates that the element does not appear in the given Collection.

intersection

public static java.util.Collection intersection(java.util.Collection a,
                                                java.util.Collection b)
Returns a Collection containing the intersection of the given Collections.

The cardinality of each element in the returned Collection will be equal to the minimum of the cardinality of that element in the two given Collections.

関連項目:
Collection.retainAll(java.util.Collection)

isEqualCollection

public static boolean isEqualCollection(java.util.Collection a,
                                        java.util.Collection b)
Returns true iff the given Collections contain exactly the same elements with exactly the same cardinality.

That is, iff the cardinality of e in a is equal to the cardinality of e in b, for each element e in a or b.


isProperSubCollection

public static boolean isProperSubCollection(java.util.Collection a,
                                            java.util.Collection b)
Returns true iff a is a proper sub-collection of b, that is, iff the cardinality of e in a is less than or equal to the cardinality of e in b, for each element e in a, and there is at least one element f such that the cardinality of f in b is strictly greater than the cardinality of f in a.
関連項目:
isSubCollection(java.util.Collection, java.util.Collection), Collection.containsAll(java.util.Collection)

isSubCollection

public static boolean isSubCollection(java.util.Collection a,
                                      java.util.Collection b)
Returns true iff a is a sub-collection of b, that is, iff the cardinality of e in a is less than or equal to the cardinality of e in b, for each element e in a.
関連項目:
isProperSubCollection(java.util.Collection, java.util.Collection), Collection.containsAll(java.util.Collection)

select

public static java.util.Collection select(java.util.Collection inputCollection,
                                          Predicate predicate)
Selects all elements from inputCollection which match the given predicate into an output collection

select

public static void select(java.util.Collection inputCollection,
                          Predicate predicate,
                          java.util.Collection outputCollection)
Selects all elements from inputCollection which match the given predicate and adds them to outputCollection

subtract

public static java.util.Collection subtract(java.util.Collection a,
                                            java.util.Collection b)
Returns a Collection containing a - b. The cardinality of each element e in the returned Collection will be the cardinality of e in a minus the cardinality of e in b, or zero, whichever is greater.
関連項目:
Collection.removeAll(java.util.Collection)

union

public static java.util.Collection union(java.util.Collection a,
                                         java.util.Collection b)
Returns a Collection containing the union of the given Collections.

The cardinality of each element in the returned Collection will be equal to the maximum of the cardinality of that element in the two given Collections.

関連項目:
Collection.addAll(java.util.Collection)


Copyright © 2001 Apache Software Foundation. Documenation generated November 5 2001.