org.apache.commons.collections.set

Class CompositeSet

Implemented Interfaces:
Collection, Set

public class CompositeSet
extends CompositeCollection
implements Set

Decorates a set of other sets to provide a single unified view.

Changes made to this set will actually be made on the decorated set. Add and remove operations require the use of a pluggable strategy. If no strategy is provided then add and remove are unsupported.

Version:
$Revision: 1.3 $ $Date: 2004/02/18 01:14:27 $
Author:
Brian McCallister
Since:
Commons Collections 3.0

Nested Class Summary

static interface
CompositeSet.SetMutator
Define callbacks for mutation operations.

Nested classes/interfaces inherited from class org.apache.commons.collections.collection.CompositeCollection

CompositeCollection.CollectionMutator

Field Summary

Fields inherited from class org.apache.commons.collections.collection.CompositeCollection

all, mutator

Constructor Summary

CompositeSet()
Create an empty CompositeSet
CompositeSet(Set set)
Create a CompositeSet with just set composited
CompositeSet(Set[] sets)
Create a composite set with sets as the initial set of composited Sets

Method Summary

void
addComposited(Collection c)
Add a Set to this composite
void
addComposited(Collection c, Collection d)
Add two sets to this composite
void
addComposited(Collection[] comps)
Add an array of sets to this composite
boolean
equals(Object obj)
int
hashCode()
boolean
remove(Object obj)
If a CollectionMutator is defined for this CompositeSet then this method will be called anyway.
void
setMutator(CompositeCollection.CollectionMutator mutator)
This can receive either a CompositeCollection.CollectionMutator or a CompositeSet.SetMutator.

Methods inherited from class org.apache.commons.collections.collection.CompositeCollection

add, addAll, addComposited, addComposited, addComposited, clear, contains, containsAll, getCollections, isEmpty, iterator, remove, removeAll, removeComposited, retainAll, setMutator, size, toArray, toArray, toCollection

Constructor Details

CompositeSet

public CompositeSet()
Create an empty CompositeSet

CompositeSet

public CompositeSet(Set set)
Create a CompositeSet with just set composited
Parameters:
set - The initial set in the composite

CompositeSet

public CompositeSet(Set[] sets)
Create a composite set with sets as the initial set of composited Sets

Method Details

addComposited

public void addComposited(Collection c)
Add a Set to this composite
Overrides:
addComposited in interface CompositeCollection
Parameters:
c - Must implement Set

addComposited

public void addComposited(Collection c,
                          Collection d)
Add two sets to this composite
Overrides:
addComposited in interface CompositeCollection

addComposited

public void addComposited(Collection[] comps)
Add an array of sets to this composite
Overrides:
addComposited in interface CompositeCollection
Parameters:
comps -

equals

public boolean equals(Object obj)
See Also:
Set.equals

hashCode

public int hashCode()
See Also:
Set.hashCode

remove

public boolean remove(Object obj)
If a CollectionMutator is defined for this CompositeSet then this method will be called anyway.
Overrides:
remove in interface CompositeCollection
Parameters:
obj - Object to be removed
Returns:
true if the object is removed, false otherwise

setMutator

public void setMutator(CompositeCollection.CollectionMutator mutator)
This can receive either a CompositeCollection.CollectionMutator or a CompositeSet.SetMutator. If a CompositeCollection.CollectionMutator is used than conflicts when adding composited sets will throw IllegalArgumentException

Overrides:
setMutator in interface CompositeCollection

Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.