wt.fc.collections
Class WTHashSet

java.lang.Object
  extended byjava.util.AbstractCollection
      extended bywt.fc.collections.AbstractWTCollection
          extended bywt.fc.collections.WTHashSet
All Implemented Interfaces:
Cloneable, Collection, Externalizable, ReferenceBased, ResultProcessor, Serializable, Set, WTCollection, WTSet
Direct Known Subclasses:
DefaultCollectionGraph

public class WTHashSet
extends AbstractWTCollection
implements Cloneable, ResultProcessor, WTSet, Externalizable

A hash-based implementation of WTSet.

WTHashSet implements wt.fc.ResultProcessor to provide better integration with the persistence layer. By implementing ResultProcessor, the default collections can be used in place of a QueryResult when retrieving data. The APIs to accomplish this are:

 PersistenceManager.find(StatementSpec, ResultProcessor)
 PersisenceManagerSvr.query(StatementSpec, ResultProcessor)
 

In addition to a no-arg clone method, WTHashSet provides a "deep" clone in which the references are copied and the Persistables in the set are cloned using PersistenceCloner.

A WTHashSet can be constructed with a key mask. The default key mask is CollectionsHelper.OBJECT_IDENTIFIER.

Supported API: true

Extendable: false

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class wt.fc.collections.AbstractWTCollection
AbstractWTCollection.PersistableCollection
 
Field Summary
private static String CLASSNAME
           
(package private)  WTKeyedHashMap data
           
(package private) static int DEFAULT_INITIAL_CAPACITY
           
(package private) static int DEFAULT_KEY_MASK
           
static long EXTERNALIZATION_VERSION_UID
           
protected static long OLD_FORMAT_VERSION_UID
           
private static Object PRESENT
           
private static String RESOURCE
           
(package private) static long serialVersionUID
           
 
Fields inherited from class wt.fc.collections.AbstractWTCollection
 
Fields inherited from interface wt.fc.collections.WTCollection
DEFLATED_ON_SERIALIZATION
 
Constructor Summary
WTHashSet()
          

Supported API: true
WTHashSet(Collection c)
          

Supported API: true
WTHashSet(Collection c, int key_mask)
          

Supported API: true
WTHashSet(int initial_capacity)
          

Supported API: true
WTHashSet(int initial_capacity, int key_mask)
          

Supported API: true
 
Method Summary
 boolean add(Persistable p)
          

Supported API: false
 boolean add(QueryKey query_key)
          

Supported API: false
 boolean add(WTReference ref)
          

Supported API: false
 void addElement(Object anObj)
          Add the specified object to the result processor, and increase the size by one

Supported API: false
 Iterator classIterator()
          

Supported API: false
 void clear()
          

Supported API: false
 Object clone()
          

Supported API: true
 WTHashSet clone(boolean deep)
          

Supported API: true
(package private)  boolean connect(WTReference r, boolean add)
          Add the reference to the collection's internal data structures
 boolean contains(QueryKey query_key)
          

Supported API: false
 boolean contains(WTReference ref)
          

Supported API: false
 boolean containsInstance(Class filter)
          

Supported API: false
protected  boolean containsNonPersisted(Persistable p)
          Attempts to remove the given non-persisted Persistable from the collection.
 boolean equals(Object o)
          

Supported API: false
static int getInitialCapacity(int size)
          Get the initial capacity that should be used for a set that is intended to hold the given number of elements.
 int getKeyMask()
          

Supported API: false
 WTReference getReference(Persistable p)
          Get a reference used internally by this collection that refers to the given Persistable.
 WTReference getReference(QueryKey q)
          Get a reference used internally by this collection that refers to the given QueryKey.
 WTReference getReference(WTReference r)
          Get a reference used internally by this collection that refers to the same object as the given reference.
 WTReference[] getReferences(WTReference r)
          Get all reference used internally by this collection that refer to the same object as the given reference.
 int hashCode()
          

Supported API: false
 void inflate()
          

Supported API: false
 boolean isDeflatedOnSerialization()
          Gets the value of the attribute: deflatedOnSerialization.
 Iterator persistableIterator()
          

Supported API: false
 Iterator persistableIterator(Class filter, boolean include_subclasses)
          

Supported API: false
 Iterator queryKeyIterator()
          

Supported API: false
 Iterator queryKeyIterator(Class filter, boolean include_subclasses)
          

Supported API: false
 void readExternal(ObjectInput input)
          Reads the non-transient fields of this class from an external source.
private  boolean readOldVersion(ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source, which is not the current version.
protected  boolean readVersion(WTHashSet thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
 Iterator referenceIterator()
          

Supported API: false
 Iterator referenceIterator(Class filter, boolean include_subclasses)
          

Supported API: false
(package private)  void referenceRemoved(WTReference r)
           
 boolean remove(QueryKey query_key)
          

Supported API: false
 boolean remove(WTReference ref)
          

Supported API: false
 boolean removeAll(Class filter, boolean include_subclasses)
          

Supported API: false
protected  boolean removeNonPersisted(Persistable p)
          Attempts to remove the given non-persisted Persistable from the collection.
 boolean retainAll(Class filter, boolean include_subclasses)
          

Supported API: false
 void setDeflatedOnSerialization(boolean a_DeflatedOnSerialization)
          Sets the value of the attribute: deflatedOnSerialization.
 int size()
          

Supported API: false
 WTCollection subCollection(Class filter, boolean include_subclasses)
          

Supported API: false
 void writeExternal(ObjectOutput output)
          Writes the non-transient fields of this class to an external source.
 
Methods inherited from class wt.fc.collections.AbstractWTCollection
add, addAll, addAll, connect, connect, connect, connect, connect, connect, connectAll, connectAll, contains, contains, containsOnly, deflate, getIteratorListener, getLastReturnedReference, isEnabled, iterator, persistableCollection, referenceAdded, remove, remove, setLastReturnedReference, subCollection, toArray, toArray, toArray, toArray, toArray, toArray, toIdArray
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface wt.fc.collections.WTCollection
add, addAll, addAll, connect, connect, connect, connect, connect, connect, connectAll, connectAll, contains, contains, containsOnly, deflate, isEnabled, iterator, persistableCollection, remove, remove, subCollection, toArray, toArray, toArray, toArray, toArray, toArray, toIdArray
 
Methods inherited from interface java.util.Collection
containsAll, isEmpty, removeAll, retainAll
 
Methods inherited from interface java.util.Set
add, addAll, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

EXTERNALIZATION_VERSION_UID

public static final long EXTERNALIZATION_VERSION_UID
See Also:
Constant Field Values

OLD_FORMAT_VERSION_UID

protected static final long OLD_FORMAT_VERSION_UID
See Also:
Constant Field Values

PRESENT

private static final Object PRESENT

DEFAULT_INITIAL_CAPACITY

static final int DEFAULT_INITIAL_CAPACITY
See Also:
Constant Field Values

DEFAULT_KEY_MASK

static final int DEFAULT_KEY_MASK
See Also:
Constant Field Values

data

transient WTKeyedHashMap data
Constructor Detail

WTHashSet

public WTHashSet()


Supported API: true


WTHashSet

public WTHashSet(int initial_capacity)


Supported API: true

Parameters:
initial_capacity -

WTHashSet

public WTHashSet(int initial_capacity,
                 int key_mask)


Supported API: true

Parameters:
initial_capacity -
key_mask -

WTHashSet

public WTHashSet(Collection c)


Supported API: true

Parameters:
c -

WTHashSet

public WTHashSet(Collection c,
                 int key_mask)


Supported API: true

Parameters:
c -
key_mask -
Method Detail

writeExternal

public void writeExternal(ObjectOutput output)
                   throws IOException
Writes the non-transient fields of this class to an external source.

Supported API: false

Specified by:
writeExternal in interface Externalizable
Parameters:
output -
Throws:
IOException

readExternal

public void readExternal(ObjectInput input)
                  throws IOException,
                         ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Specified by:
readExternal in interface Externalizable
Parameters:
input -
Throws:
IOException
ClassNotFoundException

readVersion

protected boolean readVersion(WTHashSet thisObject,
                              ObjectInput input,
                              long readSerialVersionUID,
                              boolean passThrough,
                              boolean superDone)
                       throws IOException,
                              ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Parameters:
thisObject -
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

readOldVersion

private boolean readOldVersion(ObjectInput input,
                               long readSerialVersionUID,
                               boolean passThrough,
                               boolean superDone)
                        throws IOException,
                               ClassNotFoundException
Reads the non-transient fields of this class from an external source, which is not the current version.

Parameters:
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

isDeflatedOnSerialization

public boolean isDeflatedOnSerialization()
Gets the value of the attribute: deflatedOnSerialization.

Supported API: false

Specified by:
isDeflatedOnSerialization in interface WTCollection
Overrides:
isDeflatedOnSerialization in class AbstractWTCollection
Returns:
boolean

setDeflatedOnSerialization

public void setDeflatedOnSerialization(boolean a_DeflatedOnSerialization)
                                throws WTPropertyVetoException
Sets the value of the attribute: deflatedOnSerialization.

Supported API: false

Specified by:
setDeflatedOnSerialization in interface WTCollection
Overrides:
setDeflatedOnSerialization in class AbstractWTCollection
Parameters:
a_DeflatedOnSerialization -
Throws:
WTPropertyVetoException

add

public boolean add(Persistable p)


Supported API: false

Specified by:
add in interface WTCollection
Overrides:
add in class AbstractWTCollection
Parameters:
p -
Returns:
boolean

add

public boolean add(QueryKey query_key)


Supported API: false

Specified by:
add in interface WTCollection
Overrides:
add in class AbstractWTCollection
Parameters:
query_key -
Returns:
boolean

add

public boolean add(WTReference ref)


Supported API: false

Specified by:
add in interface WTCollection
Overrides:
add in class AbstractWTCollection
Parameters:
ref -
Returns:
boolean

classIterator

public Iterator classIterator()


Supported API: false

Specified by:
classIterator in interface WTCollection
Specified by:
classIterator in class AbstractWTCollection
Returns:
Iterator

clear

public void clear()


Supported API: false

Specified by:
clear in interface Collection

clone

public Object clone()


Supported API: true

Returns:
Object

clone

public WTHashSet clone(boolean deep)


Supported API: true

Parameters:
deep -
Returns:
WTHashSet

contains

public boolean contains(QueryKey query_key)


Supported API: false

Specified by:
contains in interface WTCollection
Overrides:
contains in class AbstractWTCollection
Parameters:
query_key -
Returns:
boolean

contains

public boolean contains(WTReference ref)


Supported API: false

Specified by:
contains in interface WTCollection
Overrides:
contains in class AbstractWTCollection
Parameters:
ref -
Returns:
boolean

containsInstance

public boolean containsInstance(Class filter)


Supported API: false

Specified by:
containsInstance in interface WTCollection
Overrides:
containsInstance in class AbstractWTCollection
Parameters:
filter -
Returns:
boolean

equals

public boolean equals(Object o)


Supported API: false

Specified by:
equals in interface Collection
Overrides:
equals in class AbstractWTCollection
Parameters:
o -
Returns:
boolean

getKeyMask

public int getKeyMask()


Supported API: false

Specified by:
getKeyMask in interface WTCollection
Specified by:
getKeyMask in class AbstractWTCollection
Returns:
int

hashCode

public int hashCode()


Supported API: false

Specified by:
hashCode in interface Collection
Overrides:
hashCode in class AbstractWTCollection
Returns:
int

inflate

public void inflate()
             throws WTException


Supported API: false

Specified by:
inflate in interface WTCollection
Overrides:
inflate in class AbstractWTCollection
Throws:
WTException

persistableIterator

public Iterator persistableIterator()
                             throws WTException


Supported API: false

Specified by:
persistableIterator in interface WTCollection
Specified by:
persistableIterator in class AbstractWTCollection
Returns:
Iterator
Throws:
WTException

persistableIterator

public Iterator persistableIterator(Class filter,
                                    boolean include_subclasses)
                             throws WTException


Supported API: false

Specified by:
persistableIterator in interface WTCollection
Specified by:
persistableIterator in class AbstractWTCollection
Parameters:
filter -
include_subclasses -
Returns:
Iterator
Throws:
WTException

queryKeyIterator

public Iterator queryKeyIterator()


Supported API: false

Specified by:
queryKeyIterator in interface WTCollection
Specified by:
queryKeyIterator in class AbstractWTCollection
Returns:
Iterator

queryKeyIterator

public Iterator queryKeyIterator(Class filter,
                                 boolean include_subclasses)


Supported API: false

Specified by:
queryKeyIterator in interface WTCollection
Specified by:
queryKeyIterator in class AbstractWTCollection
Parameters:
filter -
include_subclasses -
Returns:
Iterator

referenceIterator

public Iterator referenceIterator()


Supported API: false

Specified by:
referenceIterator in interface WTCollection
Specified by:
referenceIterator in class AbstractWTCollection
Returns:
Iterator

referenceIterator

public Iterator referenceIterator(Class filter,
                                  boolean include_subclasses)


Supported API: false

Specified by:
referenceIterator in interface WTCollection
Specified by:
referenceIterator in class AbstractWTCollection
Parameters:
filter -
include_subclasses -
Returns:
Iterator

removeNonPersisted

protected boolean removeNonPersisted(Persistable p)
Attempts to remove the given non-persisted Persistable from the collection.

Supported API: false

Overrides:
removeNonPersisted in class AbstractWTCollection
Parameters:
p -
Returns:
true if the collection is modified as a result of this operation

remove

public boolean remove(QueryKey query_key)


Supported API: false

Specified by:
remove in interface WTCollection
Overrides:
remove in class AbstractWTCollection
Parameters:
query_key -
Returns:
boolean

remove

public boolean remove(WTReference ref)


Supported API: false

Specified by:
remove in interface WTCollection
Overrides:
remove in class AbstractWTCollection
Parameters:
ref -
Returns:
boolean

removeAll

public boolean removeAll(Class filter,
                         boolean include_subclasses)


Supported API: false

Specified by:
removeAll in interface WTCollection
Overrides:
removeAll in class AbstractWTCollection
Parameters:
filter -
include_subclasses -
Returns:
boolean

retainAll

public boolean retainAll(Class filter,
                         boolean include_subclasses)


Supported API: false

Specified by:
retainAll in interface WTCollection
Overrides:
retainAll in class AbstractWTCollection
Parameters:
filter -
include_subclasses -
Returns:
boolean

size

public int size()


Supported API: false

Specified by:
size in interface ResultProcessor
Returns:
int

subCollection

public WTCollection subCollection(Class filter,
                                  boolean include_subclasses)


Supported API: false

Specified by:
subCollection in interface WTCollection
Specified by:
subCollection in class AbstractWTCollection
Parameters:
filter -
include_subclasses -
Returns:
WTCollection

addElement

public void addElement(Object anObj)
Add the specified object to the result processor, and increase the size by one

Supported API: false

Specified by:
addElement in interface ResultProcessor
Parameters:
anObj -

connect

boolean connect(WTReference r,
                boolean add)
Description copied from class: AbstractWTCollection
Add the reference to the collection's internal data structures

Specified by:
connect in class AbstractWTCollection

containsNonPersisted

protected boolean containsNonPersisted(Persistable p)
Description copied from class: AbstractWTCollection
Attempts to remove the given non-persisted Persistable from the collection.

Supported API: false

Overrides:
containsNonPersisted in class AbstractWTCollection
Parameters:
p -
Returns:
true if the collection is modified as a result of this operation

referenceRemoved

void referenceRemoved(WTReference r)
Overrides:
referenceRemoved in class AbstractWTCollection

getReference

public WTReference getReference(Persistable p)
Description copied from class: AbstractWTCollection
Get a reference used internally by this collection that refers to the given Persistable. If there is more than one reference to the persistable, then the particular reference that is returned is arbitrary

Specified by:
getReference in interface ReferenceBased
Overrides:
getReference in class AbstractWTCollection
Parameters:
p -
Returns:
WTReference The reference or null

getReference

public WTReference getReference(QueryKey q)
Description copied from class: AbstractWTCollection
Get a reference used internally by this collection that refers to the given QueryKey. If there is more than one reference to the key, then the particular reference that is returned is arbitrary

Specified by:
getReference in interface ReferenceBased
Overrides:
getReference in class AbstractWTCollection
Parameters:
q -
Returns:
WTReference The reference or null

getReference

public WTReference getReference(WTReference r)
Description copied from class: AbstractWTCollection
Get a reference used internally by this collection that refers to the same object as the given reference. If there is more than one matching reference, then the particular reference that is returned is arbitrary

Specified by:
getReference in interface ReferenceBased
Overrides:
getReference in class AbstractWTCollection
Parameters:
r -
Returns:
WTReference The reference or null

getReferences

public WTReference[] getReferences(WTReference r)
Description copied from class: AbstractWTCollection
Get all reference used internally by this collection that refer to the same object as the given reference. This is used by inflate.

Specified by:
getReferences in interface ReferenceBased
Overrides:
getReferences in class AbstractWTCollection
Parameters:
r -
Returns:
WTReference The reference or null

getInitialCapacity

public static int getInitialCapacity(int size)
Get the initial capacity that should be used for a set that is intended to hold the given number of elements.

Parameters:
size - The number of elements that will be added to the new set
Returns:
The optimal initial capacity for the new set