Oracle Application Development Framework Model and Business Components Java API Reference 10g Release 3 (10.1.3)
B16005-01


oracle.jbo.server.java.util
Class AbstractSet

java.lang.Object
  extended byoracle.jbo.server.java.util.AbstractCollection
      extended byoracle.jbo.server.java.util.AbstractSet

All Implemented Interfaces:
Collection, Set
Direct Known Subclasses:
ArraySet

public abstract class AbstractSet
extends AbstractCollection
implements Set

This class provides a skeletal implementation of the Set interface to minimize the effort required to implement this interface.

The process of implementing a Set by extending this class is identical to that of implementing a Collection by extending AbstractCollection, except that all of the methods and constructors in subclasses of this class must obey the additional constraints imposed by the Set interface (for instance, the add method must not permit addition of multiple intances of an object to a Set).

Note that this class does not override any of the implementations from abstractCollection. It merely adds implementations for equals and hashCode.

Since:
JDK1.2
See Also:
Collection, AbstractCollection, Set

Constructor Summary
AbstractSet()
           

 

Method Summary
 boolean equals(java.lang.Object o)
          Compares the specified Object with this Set for equality.
 int hashCode()
          Returns the hash code value for this Set.

 

Methods inherited from class oracle.jbo.server.java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toString

 

Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait

 

Methods inherited from interface oracle.jbo.server.java.util.Set
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray

 

Constructor Detail

AbstractSet

public AbstractSet()

Method Detail

equals

public boolean equals(java.lang.Object o)
Compares the specified Object with this Set for equality. Returns true if the given object is also a Set, the two Sets have the same size, and every member of the given Set is contained in this Set. This ensures that the equals method works properly accross different implementations of the Set interface.

This implementation first checks if the specified Object is this Set; if so it returns true. Then, it checks if the specified Object is a Set whose size is identical to the size of this Set; if not, it it returns false. If so, it returns containsAll((Collection) o).

Specified by:
equals in interface Set
Parameters:
o - Object to be compared for equality with this Set.
Returns:
true if the specified Object is equal to this Set.
Since:
JDK1.2

hashCode

public int hashCode()
Returns the hash code value for this Set. The hash code of a Set is defined to be the sum of the hashCodes of the elements in the Set. This ensures that s1.equals(s2) implies that s1.hashCode()==s2.hashCode() for any two Sets s1 and s2, as required by the general contract of Object.hashCode.

This implementation enumerates over the Set, calling hashCode on each element in the Collection, and adding up the results.

Specified by:
hashCode in interface Set
Since:
JDK1.2

Oracle Application Development Framework Model and Business Components Java API Reference 10g Release 3 (10.1.3)
B16005-01


Copyright © 1997, 2005, Oracle. All rights reserved.