deegree 2.1 (2007/11/08 09:57 build-328-official)

org.deegree.model.csct.resources
Class WeakHashSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet
          extended by org.deegree.model.csct.resources.WeakHashSet
All Implemented Interfaces:
Iterable, Collection, Set

public class WeakHashSet
extends AbstractSet

A set of object hold by weak references. This class is used to implements caches.

Version:
1.0
Author:
Martin Desruisseaux

Constructor Summary
WeakHashSet()
          Construct a WeakHashSet.
 
Method Summary
 boolean add(Object obj)
          Adds the specified element to this set if it is not already present.
 void clear()
          Removes all of the elements from this set.
 boolean contains(Object obj)
          Returns true if this set contains the specified element.
protected  boolean equals(Object object1, Object object2)
          Check two objects for equality.
 Object get(Object obj)
          Returns an object equals to the specified object, if present.
protected  int hashCode(Object object)
          Returns a hash code value for the specified object.
 Object intern(Object object)
          Returns an object equals to obj if such an object already exist in this WeakHashSet.
 void intern(Object[] objects)
          Iteratively call intern(Object) for an array of objects.
 Iterator iterator()
          Returns an iterator over the elements contained in this collection.
 int size()
          Returns the count of element in this set.
 Object[] toArray()
          Returns a view of this set as an array.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, remove, retainAll, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, isEmpty, remove, retainAll, toArray
 

Constructor Detail

WeakHashSet

public WeakHashSet()
Construct a WeakHashSet.

Method Detail

contains

public boolean contains(Object obj)
Returns true if this set contains the specified element.

Specified by:
contains in interface Collection
Specified by:
contains in interface Set
Overrides:
contains in class AbstractCollection
Parameters:
obj - Object to be checked for containment in this set.
Returns:
true if this set contains the specified element.

get

public final Object get(Object obj)
Returns an object equals to the specified object, if present. If this set doesn't contains any object equals to obj, then this method returns null.


add

public boolean add(Object obj)
Adds the specified element to this set if it is not already present. If this set already contains the specified element, the call leaves this set unchanged and returns false.

Specified by:
add in interface Collection
Specified by:
add in interface Set
Overrides:
add in class AbstractCollection
Parameters:
obj - Element to be added to this set.
Returns:
true if this set did not already contain the specified element.

intern

public final Object intern(Object object)
Returns an object equals to obj if such an object already exist in this WeakHashSet. Otherwise, add obj to this WeakHashSet. This method is equivalents to the following code:
    if (object!=null)
    {
        final Object current=get(object);
        if (current!=null) return current;
        else add(object);
    }
    return object;
 


intern

public final void intern(Object[] objects)
Iteratively call intern(Object) for an array of objects. This method is equivalents to the following code:
    for (int i=0; i


size

public final int size()
Returns the count of element in this set.

Specified by:
size in interface Collection
Specified by:
size in interface Set
Specified by:
size in class AbstractCollection

clear

public final void clear()
Removes all of the elements from this set.

Specified by:
clear in interface Collection
Specified by:
clear in interface Set
Overrides:
clear in class AbstractCollection

toArray

public final Object[] toArray()
Returns a view of this set as an array. Elements will be in an arbitrary order. Note that this array contains strong reference. Consequently, no object reclamation will occurs as long as a reference to this array is hold.

Specified by:
toArray in interface Collection
Specified by:
toArray in interface Set
Overrides:
toArray in class AbstractCollection

iterator

public Iterator iterator()
Returns an iterator over the elements contained in this collection. No element from this set will be garbage collected as long as a reference to the iterator is hold.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface Set
Specified by:
iterator in class AbstractCollection

hashCode

protected int hashCode(Object object)
Returns a hash code value for the specified object. Default implementation returns Object.hashCode(). Override to compute hash code in a different way.


equals

protected boolean equals(Object object1,
                         Object object2)
Check two objects for equality. This method should be overriden if hashCode(Object) has been overriden.


deegree 2.1 (2007/11/08 09:57 build-328-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://deegree.sourceforge.net