org.apache.commons.collections.collection
public class CompositeCollection extends Object implements Collection
Changes made to this collection will actually be made on the decorated collection. Add and remove operations require the use of a pluggable strategy. If no strategy is provided then add and remove are unsupported.
Since: Commons Collections 3.0
Version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
Nested Class Summary | |
---|---|
interface | CompositeCollection.CollectionMutator
Pluggable strategy to handle changes to the composite. |
Field Summary | |
---|---|
protected Collection[] | all Collections in the composite |
protected CompositeCollection.CollectionMutator | mutator CollectionMutator to handle changes to the collection |
Constructor Summary | |
---|---|
CompositeCollection()
Create an empty CompositeCollection. | |
CompositeCollection(Collection coll)
Create a Composite Collection with only coll composited.
| |
CompositeCollection(Collection[] colls)
Create a CompositeCollection with colls as the initial list of
composited collections.
|
Method Summary | |
---|---|
boolean | add(Object obj)
Adds an object to the collection, throwing UnsupportedOperationException
unless a CollectionMutator strategy is specified.
|
boolean | addAll(Collection coll)
Adds a collection of elements to this collection, throwing
UnsupportedOperationException unless a CollectionMutator strategy is specified.
|
void | addComposited(Collection[] comps)
Add these Collections to the list of collections in this composite
|
void | addComposited(Collection c)
Add an additional collection to this composite.
|
void | addComposited(Collection c, Collection d)
Add two additional collections to this composite.
|
void | clear()
Removes all of the elements from this collection .
|
boolean | contains(Object obj)
Checks whether this composite collection contains the object.
|
boolean | containsAll(Collection coll)
Checks whether this composite contains all the elements in the specified collection.
|
Collection | getCollections()
Gets the collections being decorated.
|
boolean | isEmpty()
Checks whether this composite collection is empty.
|
Iterator | iterator()
Gets an iterator over all the collections in this composite.
|
boolean | remove(Object obj)
Removes an object from the collection, throwing UnsupportedOperationException
unless a CollectionMutator strategy is specified.
|
boolean | removeAll(Collection coll)
Removes the elements in the specified collection from this composite collection.
|
void | removeComposited(Collection coll)
Removes a collection from the those being decorated in this composite.
|
boolean | retainAll(Collection coll)
Retains all the elements in the specified collection in this composite collection,
removing all others.
|
void | setMutator(CompositeCollection.CollectionMutator mutator)
Specify a CollectionMutator strategy instance to handle changes.
|
int | size()
Gets the size of this composite collection.
|
Object[] | toArray()
Returns an array containing all of the elements in this composite.
|
Object[] | toArray(Object[] array)
Returns an object array, populating the supplied array if possible.
|
Collection | toCollection()
Returns a new collection containing all of the elements
|
Parameters: coll a collection to decorate
Parameters: colls an array of collections to decorate
Parameters: obj the object to add
Returns: true if the collection was modified
Throws: UnsupportedOperationException if CollectionMutator hasn't been set UnsupportedOperationException if add is unsupported ClassCastException if the object cannot be added due to its type NullPointerException if the object cannot be added because its null IllegalArgumentException if the object cannot be added
Parameters: coll the collection to add
Returns: true if the collection was modified
Throws: UnsupportedOperationException if CollectionMutator hasn't been set UnsupportedOperationException if add is unsupported ClassCastException if the object cannot be added due to its type NullPointerException if the object cannot be added because its null IllegalArgumentException if the object cannot be added
Parameters: comps Collections to be appended to the composite
Parameters: c the collection to add
Parameters: c the first collection to add d the second collection to add
This implementation calls clear()
on each collection.
Throws: UnsupportedOperationException if clear is unsupported
This implementation calls contains()
on each collection.
Parameters: obj the object to search for
Returns: true if obj is contained in any of the contained collections
This implementation calls contains()
for each element in the
specified collection.
Parameters: coll the collection to check for
Returns: true if all elements contained
Returns: Unmodifiable collection of all collections in this composite.
This implementation calls isEmpty()
on each collection.
Returns: true if all of the contained collections are empty
This implementation uses an IteratorChain
.
Returns: an IteratorChain
instance which supports
remove()
. Iteration occurs over contained collections in
the order they were added, but this behavior should not be relied upon.
See Also: IteratorChain
Parameters: obj the object being removed
Returns: true if the collection is changed
Throws: UnsupportedOperationException if removed is unsupported ClassCastException if the object cannot be removed due to its type NullPointerException if the object cannot be removed because its null IllegalArgumentException if the object cannot be removed
This implementation calls removeAll
on each collection.
Parameters: coll the collection to remove
Returns: true if the collection was modified
Throws: UnsupportedOperationException if removeAll is unsupported
Parameters: coll collection to be removed
This implementation calls retainAll()
on each collection.
Parameters: coll the collection to remove
Returns: true if the collection was modified
Throws: UnsupportedOperationException if retainAll is unsupported
Parameters: mutator the mutator to use
This implementation calls size()
on each collection.
Returns: total number of elements in all contained containers
Returns: an object array of all the elements in the collection
Collection
interface for full details.
Parameters: array the array to use, populating if possible
Returns: an array of all the elements in the collection
Returns: A new ArrayList containing all of the elements in this composite. The new collection is not backed by this composite.