public class Set
extends java.lang.Object
implements java.lang.Cloneable
One commonly used subclass is CertificateSet.
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Class |
m_class |
protected java.util.Vector |
m_set |
| Constructor and Description |
|---|
Set(java.lang.Class contentClass)
Constructs a
Set object specifying the class of the objects
that can be added to this set. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addElement(java.lang.Object obj)
Adds an object to the set.
|
Set |
apply(Selector selector)
Removes all objects from this set that do not conform to
selector's criteria. |
java.util.Enumeration |
elements()
Returns an enumeration of the elements of this set.
|
java.lang.Class |
getContentClass()
Returns the class of the content objects.
|
java.lang.Object[] |
getElements()
Returns all objects contained in this set.
|
Set |
intersect(Set operand)
The intersection set operation.
|
void |
removeAll()
Removes all objects from the set.
|
boolean |
removeElement(java.lang.Object obj)
Searches the set for an object that is equivalent to
obj
and removes it. |
int |
size()
Returns the number of objects stored in this set.
|
Set |
substract(Set operand)
The difference (or subtraction) set operation.
|
Set |
union(Set operand)
The union set operation.
|
public Set(java.lang.Class contentClass)
throws java.lang.NullPointerException
Set object specifying the class of the objects
that can be added to this set.contentClass - any object added to this set is checked against this classjava.lang.NullPointerException - if contentClass is nullpublic java.lang.Class getContentClass()
public final boolean addElement(java.lang.Object obj)
throws java.lang.ClassCastException,
java.lang.NullPointerException
The object added to the set must be an instance of the class specified
in the constructor, or an instance of a subclass of the class specified
in the constructor. If the object is already in the set, it is not added.
The comparison with members of the set is done using the object's
equals method.
obj - the object to add to the this settrue if obj is added to this set,
false otherwise - that is, because an equivalent
object is already a member of the setjava.lang.ClassCastException - thrown if obj is not an instance of the class
specified in the constructorjava.lang.NullPointerException - thrown if obj is nullpublic final boolean removeElement(java.lang.Object obj)
throws java.lang.NullPointerException
obj
and removes it.
The object's equals method is used for the comparison.
obj does not have to be contained in the set;
it is sufficient if there is an object obj2 such that
obj.equals(obj2).
obj - if the set contains an object that is equal to obj,
it is removedtrue if an object was found and removed,
false if no object equal to obj was
foundjava.lang.NullPointerException - if obj is nullpublic final void removeAll()
public final java.lang.Object[] getElements()
0.public final java.util.Enumeration elements()
Enumerationpublic final int size()
public final Set union(Set operand) throws java.lang.ClassCastException, java.lang.NullPointerException
This method creates a new set containing all objects that are either
in the calling set, in operand, or in both.
The objects of the two sets are compared using the equals
method.
If an object in the calling set equals an object in operand,
only the calling set's object are included in the new set. Neither the calling
set nor operand are changed by this operation.
The returned set is created by cloning the set so it is of the same class
as the calling set. The objects in operand must be of the class
specified in the calling set's constructor.
operand - the set to be combined with the calling setoperandjava.lang.ClassCastException - thrown if operand contains an object that is not of
the class specified in the calling set's constructorjava.lang.NullPointerException - thrown if operand is nullpublic final Set intersect(Set operand) throws java.lang.NullPointerException
This method creates a new set containing all objects that are common to
both the calling set and operand. The objects of the two sets are
compared using the equals method.
Neither the calling set nor operand are changed by this operation.
The returned set is created by cloning the set so it is of the same class
as the calling set.
operand - the set to be compared with the calling setoperandjava.lang.NullPointerException - thrown if operand is nullpublic final Set substract(Set operand) throws java.lang.NullPointerException
Creates a new set containing all objects that are contained in this set,
but not in operand. The objects of the two sets are
compared using the equals method.
Neither this set nor operand are changed by this operation.
The returned set is created by cloning this set so it is of the same class
as this set.
operand - the set to be compared with this setoperandjava.lang.NullPointerException - thrown if operand is nullpublic final Set apply(Selector selector) throws java.lang.ClassCastException, java.lang.NullPointerException
selector's criteria.
This method calls the selector's applyTo method.
It returns a reference to itself so that calls to this method can be nested.
selector - the selector to apply to this setjava.lang.ClassCastException - thrown if the selector does not know the class specified in this
set's constructorjava.lang.NullPointerException - thrown if selector is null