org.ozoneDB.collections
Class AbstractOzoneSet
java.lang.Object
org.ozoneDB.OzoneObject
org.ozoneDB.collections.AbstractOzoneCollection
org.ozoneDB.collections.AbstractOzoneSet
- All Implemented Interfaces:
- java.util.Collection, OzoneCollection, org.ozoneDB.OzoneCompatible, org.ozoneDB.OzoneCompatibleOrProxy, org.ozoneDB.OzoneRemote, OzoneSet, java.io.Serializable, java.util.Set
- Direct Known Subclasses:
- _AbstractOzoneMap_values, _BaseTreeMap_entrySet, _BaseTreeMap_keySet, _BaseTreeMap_SubMap_entrySet, _BaseTreeMap_SubMap_keySet, BaseTreeSetImpl
- public abstract class AbstractOzoneSet
- extends AbstractOzoneCollection
- implements OzoneSet
An abstract implementation of Set to make it easier to create your own
implementations. In order to create a Set, subclass AbstractOzoneSet and
implement the same methods that are required for AbstractOzoneCollection
(although these methods must of course meet the requirements that Set puts
on them - specifically, no element may be in the set more than once). This
class simply provides implementations of equals() and hashCode() to fulfil
the requirements placed on them by the Set interface.
- Author:
- Original author unknown, Eric Blake , Leo Mekenkamp (mind the anti-sp@m) (adaptation for ozone)
- See Also:
AbstractSet
,
Serialized Form
Method Summary |
boolean |
equals(java.lang.Object o)
Tests whether the given object is equal to this Set. |
java.util.Set |
getClientSet()
Returns a non-ozone Set that contains the same
entries as this persistent one; it is (by nature of the client-server
enviromnent) always a 'deep' copy of this OzoneSet .
|
int |
hashCode()
Returns a hash code for this Set. |
boolean |
removeAll(java.util.Collection c)
Removes from this set all elements in the given collection (optional
operation). |
Methods inherited from class org.ozoneDB.collections.AbstractOzoneCollection |
add, addAll, clear, contains, containsAll, getClientCollection, isEmpty, iterator, remove, retainAll, size, toArray, toArray, toString |
Methods inherited from class org.ozoneDB.OzoneObject |
container, database, deleteRecursive, getHandle, getObjectID, handle, onActivate, onCreate, onDelete, onPassivate, requireWriteLocking, self, setContainer, toXML |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
contains, containsAll, isEmpty, iterator, size, toArray, toArray |
Methods inherited from interface org.ozoneDB.OzoneCompatibleOrProxy |
getObjectID |
Methods inherited from interface java.util.Set |
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, retainAll, size, toArray, toArray |
AbstractOzoneSet
protected AbstractOzoneSet()
equals
public boolean equals(java.lang.Object o)
- Tests whether the given object is equal to this Set. This implementation
first checks whether this set is the given object, and returns
true if so. Otherwise, if o is a Set and is the same size as this one, it
returns the result of calling containsAll on the given Set. Otherwise, it
returns false.
- Specified by:
equals
in interface java.util.Collection
- Parameters:
o
- the Object to be tested for equality with this Set
- Returns:
- true if the given object is equal to this Set
hashCode
public int hashCode()
- Returns a hash code for this Set. The hash code of a Set is the sum of the
hash codes of all its elements, except that the hash code of null is
defined to be zero. This implementation obtains an Iterator over the Set,
and sums the results.
- Specified by:
hashCode
in interface java.util.Collection
- Returns:
- a hash code for this Set
removeAll
public boolean removeAll(java.util.Collection c)
- Removes from this set all elements in the given collection (optional
operation). This implementation uses
size()
to determine
the smaller collection. Then, if this set is smaller, it iterates
over the set, calling Iterator.remove if the collection contains
the element. If this set is larger, it iterates over the collection,
calling Set.remove for all elements in the collection. Note that
this operation will fail if a remove methods is not supported.
- Specified by:
removeAll
in interface OzoneCollection
- Overrides:
removeAll
in class AbstractOzoneCollection
- Parameters:
c
- the collection of elements to remove
- Returns:
- true if the set was modified as a result
- Throws:
java.lang.UnsupportedOperationException
- if remove is not supported
java.lang.NullPointerException
- if the collection is null- See Also:
AbstractCollection.remove(Object)
,
Collection.contains(Object)
,
Iterator.remove()
getClientSet
public java.util.Set getClientSet()
Returns a non-ozone Set
that contains the same
entries as this persistent one; it is (by nature of the client-server
enviromnent) always a 'deep' copy of this OzoneSet
.
I.e. the contents of this OzoneSet
instance are
always copied to the client by use of serialization.
This means that if this instance holds non-ozone objects, these
objects are send to the calling client by means of serialization. If
this instance holds ozone objects, it actually holds proxies to these
objects. These proxies are copied and send to the client, resulting in
different proxies to the same ozone objects.
- Specified by:
getClientSet
in interface OzoneSet
Copyright © 2004 The Ozone Database Project - www.ozone-db.org. All Rights Reserved.