java.lang.Object | |
↳ | org.apache.commons.collections.collection.CompositeCollection |
Known Direct Subclasses |
Decorates a collection of other collections to provide a single unified view.
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.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CompositeCollection.CollectionMutator | Pluggable strategy to handle changes to the composite. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
all | Collections in the composite | ||||||||||
mutator | CollectionMutator to handle changes to the collection |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create an empty CompositeCollection.
| |||||||||||
Create a Composite Collection with only coll composited.
| |||||||||||
Create a CompositeCollection with colls as the initial list of
composited collections.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds an object to the collection, throwing UnsupportedOperationException
unless a CollectionMutator strategy is specified.
| |||||||||||
Adds a collection of elements to this collection, throwing
UnsupportedOperationException unless a CollectionMutator strategy is specified.
| |||||||||||
Add two additional collections to this composite.
| |||||||||||
Add an additional collection to this composite.
| |||||||||||
Add these Collections to the list of collections in this composite
| |||||||||||
Removes all of the elements from this collection .
| |||||||||||
Checks whether this composite collection contains the object.
| |||||||||||
Checks whether this composite contains all the elements in the specified collection.
| |||||||||||
Gets the collections being decorated.
| |||||||||||
Checks whether this composite collection is empty.
| |||||||||||
Gets an iterator over all the collections in this composite.
| |||||||||||
Removes an object from the collection, throwing UnsupportedOperationException
unless a CollectionMutator strategy is specified.
| |||||||||||
Removes the elements in the specified collection from this composite collection.
| |||||||||||
Removes a collection from the those being decorated in this composite.
| |||||||||||
Retains all the elements in the specified collection in this composite collection,
removing all others.
| |||||||||||
Specify a CollectionMutator strategy instance to handle changes.
| |||||||||||
Gets the size of this composite collection.
| |||||||||||
Returns an array containing all of the elements in this composite.
| |||||||||||
Returns an object array, populating the supplied array if possible.
| |||||||||||
Returns a new collection containing all of the elements
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Iterable
| |||||||||||
From interface
java.util.Collection
|
CollectionMutator to handle changes to the collection
Create an empty CompositeCollection.
Create a Composite Collection with only coll composited.
coll | a collection to decorate |
---|
Create a CompositeCollection with colls as the initial list of composited collections.
colls | an array of collections to decorate |
---|
Adds an object to the collection, throwing UnsupportedOperationException unless a CollectionMutator strategy is specified.
obj | the object to add |
---|
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 |
Adds a collection of elements to this collection, throwing UnsupportedOperationException unless a CollectionMutator strategy is specified.
coll | the collection to add |
---|
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 |
Add two additional collections to this composite.
c | the first collection to add |
---|---|
d | the second collection to add |
Add an additional collection to this composite.
c | the collection to add |
---|
Add these Collections to the list of collections in this composite
comps | Collections to be appended to the composite |
---|
Removes all of the elements from this collection .
This implementation calls clear()
on each collection.
UnsupportedOperationException | if clear is unsupported |
---|
Checks whether this composite collection contains the object.
This implementation calls contains()
on each collection.
obj | the object to search for |
---|
Checks whether this composite contains all the elements in the specified collection.
This implementation calls contains()
for each element in the
specified collection.
coll | the collection to check for |
---|
Gets the collections being decorated.
Checks whether this composite collection is empty.
This implementation calls isEmpty()
on each collection.
Gets an iterator over all the collections in this composite.
This implementation uses an IteratorChain
.
IteratorChain
instance which supports
remove()
. Iteration occurs over contained collections in
the order they were added, but this behavior should not be relied upon.Removes an object from the collection, throwing UnsupportedOperationException unless a CollectionMutator strategy is specified.
obj | the object being removed |
---|
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 |
Removes the elements in the specified collection from this composite collection.
This implementation calls removeAll
on each collection.
coll | the collection to remove |
---|
UnsupportedOperationException | if removeAll is unsupported |
---|
Removes a collection from the those being decorated in this composite.
coll | collection to be removed |
---|
Retains all the elements in the specified collection in this composite collection, removing all others.
This implementation calls retainAll()
on each collection.
coll | the collection to remove |
---|
UnsupportedOperationException | if retainAll is unsupported |
---|
Specify a CollectionMutator strategy instance to handle changes.
mutator | the mutator to use |
---|
Gets the size of this composite collection.
This implementation calls size()
on each collection.
Returns an array containing all of the elements in this composite.
Returns an object array, populating the supplied array if possible.
See Collection
interface for full details.
array | the array to use, populating if possible |
---|
Returns a new collection containing all of the elements