|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.collections15.collection.CompositeCollection<E>
public class CompositeCollection<E>
Decorates a collection of other collections15 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 Class Summary | |
|---|---|
static interface |
CompositeCollection.CollectionMutator<E>
Pluggable strategy to handle changes to the composite. |
| Field Summary | |
|---|---|
protected Collection<E>[] |
all
Collections in the composite |
protected CompositeCollection.CollectionMutator<E> |
mutator
CollectionMutator to handle changes to the collection |
| Constructor Summary | |
|---|---|
CompositeCollection()
Create an empty CompositeCollection. |
|
CompositeCollection(Collection<E>... colls)
Create a CompositeCollection with colls as the initial list of composited collections15. |
|
CompositeCollection(Collection<E> coll)
Create a Composite Collection with only coll composited. |
|
| Method Summary | ||
|---|---|---|
boolean |
add(E obj)
Adds an object to the collection, throwing UnsupportedOperationException unless a CollectionMutator strategy is specified. |
|
boolean |
addAll(Collection<? extends E> coll)
Adds a collection of elements to this collection, throwing UnsupportedOperationException unless a CollectionMutator strategy is specified. |
|
void |
addComposited(Collection<? extends E>... comps)
Add these Collections to the list of collections15 in this composite |
|
void |
addComposited(Collection<? extends E> c)
Add an additional collection to this composite. |
|
void |
addComposited(Collection<? extends E> c,
Collection<? extends E> d)
Deprecated. Superceded by the variable argument implementation of addComposited() |
|
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<Collection<E>> |
getCollections()
Gets the collections15 being decorated. |
|
boolean |
isEmpty()
Checks whether this composite collection is empty. |
|
Iterator<E> |
iterator()
Gets an iterator over all the collections15 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<? extends E> 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<E> mutator)
Specify a CollectionMutator strategy instance to handle changes. |
|
int |
size()
Gets the size of this composite collection. |
|
E[] |
toArray()
Returns an array containing all of the elements in this composite. |
|
|
toArray(E[] array)
Returns an object array, populating the supplied array if possible. |
|
Collection<E> |
toCollection()
Returns a new collection containing all of the elements |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
|---|
equals, hashCode |
| Field Detail |
|---|
protected CompositeCollection.CollectionMutator<E> mutator
protected Collection<E>[] all
| Constructor Detail |
|---|
public CompositeCollection()
public CompositeCollection(Collection<E> coll)
coll - a collection to decoratepublic CompositeCollection(Collection<E>... colls)
colls - a variable number of collections15 to decorate| Method Detail |
|---|
public int size()
size() on each collection.
size in interface Collection<E>public boolean isEmpty()
isEmpty() on each collection.
isEmpty in interface Collection<E>public boolean contains(Object obj)
contains() on each collection.
contains in interface Collection<E>obj - the object to search for
public Iterator<E> iterator()
IteratorChain.
iterator in interface Iterable<E>iterator in interface Collection<E>IteratorChain instance which supports
remove(). Iteration occurs over contained collections15 in
the order they were added, but this behavior should not be relied upon.IteratorChainpublic E[] toArray()
toArray in interface Collection<E>public <E> E[] toArray(E[] array)
Collection interface for full details.
toArray in interface Collection<E>array - the array to use, populating if possible
public boolean add(E obj)
add in interface Collection<E>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 addedpublic boolean remove(Object obj)
remove in interface Collection<E>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 removedpublic boolean containsAll(Collection<?> coll)
contains() for each element in the
specified collection.
containsAll in interface Collection<E>coll - the collection to check for
public boolean addAll(Collection<? extends E> coll)
addAll in interface Collection<E>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 addedpublic boolean removeAll(Collection<?> coll)
removeAll on each collection.
removeAll in interface Collection<E>coll - the collection to remove
UnsupportedOperationException - if removeAll is unsupportedpublic boolean retainAll(Collection<?> coll)
retainAll() on each collection.
retainAll in interface Collection<E>coll - the collection to remove
UnsupportedOperationException - if retainAll is unsupportedpublic void clear()
clear() on each collection.
clear in interface Collection<E>UnsupportedOperationException - if clear is unsupportedpublic void setMutator(CompositeCollection.CollectionMutator<E> mutator)
mutator - the mutator to usepublic void addComposited(Collection<? extends E>... comps)
comps - Collections to be appended to the compositepublic void addComposited(Collection<? extends E> c)
c - the collection to add
public void addComposited(Collection<? extends E> c,
Collection<? extends E> d)
c - the first collection to addd - the second collection to addpublic void removeComposited(Collection<? extends E> coll)
coll - collection to be removedpublic Collection<E> toCollection()
public Collection<Collection<E>> getCollections()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||