wt.fc.collections
Class WTKeyedHashMap.KeySet

java.lang.Object
  extended byjava.util.AbstractCollection
      extended bywt.fc.collections.AbstractWTCollection
          extended bywt.fc.collections.WTKeyedHashMap.KeySet
All Implemented Interfaces:
Collection, ReferenceBased, Serializable, Set, WTCollection, WTSet
Direct Known Subclasses:
WTKeyedHashMap.FilteredSet
Enclosing class:
WTKeyedHashMap

class WTKeyedHashMap.KeySet
extends AbstractWTCollection
implements WTSet, ReferenceBased, Serializable


Nested Class Summary
 
Nested classes inherited from class wt.fc.collections.AbstractWTCollection
AbstractWTCollection.PersistableCollection
 
Field Summary
 
Fields inherited from class wt.fc.collections.AbstractWTCollection
 
Fields inherited from interface wt.fc.collections.WTCollection
DEFLATED_ON_SERIALIZATION
 
Constructor Summary
(package private) WTKeyedHashMap.KeySet()
           
 
Method Summary
 Iterator classIterator()
          Returns an iterator over the classes that have instances in this collection.
 void clear()
           
(package private)  boolean connect(WTReference r, boolean add)
          Add the reference to the collection's internal data structures
 boolean contains(QueryKey id)
          Determines if the collection contains the given object in some form.
 boolean contains(WTReference ref)
          Determines if the collection contains the given object in some form.
 boolean containsInstance(Class filter)
          Returns true if there is at least one object in the collection that the filter class is assignable from.
protected  boolean containsNonPersisted(Persistable p)
          Attempts to remove the given non-persisted Persistable from the collection.
 int getKeyMask()
          Returns this collection's key mask.
 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 key.
 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 the references used internally by this collection that refers to the given reference.
 Collection persistableCollection()
          Provides a Persistable-based view of the objects in this WTCollection.
 Iterator persistableIterator()
          Returns an iterator over the objects in this collection, as Persistables.
 Iterator persistableIterator(Class filter, boolean include_subclasses)
          Refines persistableIterator() to only return objects that are either direct or descendent instances of the filter class, depending on the value of include_subclasses.
 Iterator queryKeyIterator()
          Returns an iterator over the QueryKeys in this collection.
 Iterator queryKeyIterator(Class filter, boolean include_subclasses)
          Refines queryKeyIterator() to only return keys that are either direct or descendent instances of the filter class, depending on the value of include_subclasses.
 Iterator referenceIterator()
          Returns an Iterator over the objects in this collection, as WTReferences.
 Iterator referenceIterator(Class filter, boolean include_subclasses)
          Refines referenceIterator() to only return references that are either direct or descendent instances of the filter class, depending on the value of include_subclasses.
 void referenceRemoved(WTReference r)
           
 boolean remove(QueryKey id)
          Removes the object from this collection.
 boolean remove(WTReference ref)
          Removes the object from this collection.
 boolean removeAll(Class filter, boolean include_subclasses)
          Removes all objects in this collection that are assignable from the given class.
protected  boolean removeNonPersisted(Persistable p)
          Attempts to remove the given non-persisted Persistable from the collection.
 boolean retainAll(Class filter, boolean include_subclasses)
          Removes all objects in this collection that are not assignable from the given class.
 int size()
           
 WTCollection subCollection(Class filter, boolean include_subclasses)
          Returns a sub collection of all the objects in this collection that are either direct or descendent instances of the filter class, depending on the value of include_subclasses.
(package private)  Object writeReplace()
          Externalize a key set as a plain WTHashSet
 
Methods inherited from class wt.fc.collections.AbstractWTCollection
add, add, add, add, addAll, addAll, connect, connect, connect, connect, connect, connect, connectAll, connectAll, contains, contains, containsOnly, deflate, equals, getIteratorListener, getLastReturnedReference, hashCode, inflate, isDeflatedOnSerialization, isEnabled, iterator, referenceAdded, remove, remove, setDeflatedOnSerialization, 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
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface wt.fc.collections.WTCollection
add, add, add, add, addAll, addAll, connect, connect, connect, connect, connect, connect, connectAll, connectAll, contains, contains, containsOnly, deflate, inflate, isDeflatedOnSerialization, isEnabled, iterator, remove, remove, setDeflatedOnSerialization, subCollection, toArray, toArray, toArray, toArray, toArray, toArray, toIdArray
 
Methods inherited from interface java.util.Collection
containsAll, equals, hashCode, isEmpty, removeAll, retainAll
 
Methods inherited from interface java.util.Set
add, addAll, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

WTKeyedHashMap.KeySet

WTKeyedHashMap.KeySet()
Method Detail

writeReplace

Object writeReplace()
              throws ObjectStreamException
Externalize a key set as a plain WTHashSet

Throws:
ObjectStreamException

classIterator

public Iterator classIterator()
Description copied from interface: WTCollection
Returns an iterator over the classes that have instances in this collection. A remove() from the iterator removes all the instances of the class from the collection.

Supported API: true

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

clear

public void clear()
Specified by:
clear in interface Collection

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

contains

public boolean contains(QueryKey id)
Description copied from interface: WTCollection
Determines if the collection contains the given object in some form. See WTCollection.contains(Object) for further documentation.

Supported API: true

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

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

contains

public boolean contains(WTReference ref)
Description copied from interface: WTCollection
Determines if the collection contains the given object in some form. See WTCollection.contains(Object) for further documentation.

Supported API: true

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

containsInstance

public boolean containsInstance(Class filter)
Description copied from interface: WTCollection
Returns true if there is at least one object in the collection that the filter class is assignable from.

Supported API: true

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

referenceRemoved

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

getReference

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

Supported API: false

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 interface: ReferenceBased
Get a reference used internally by this collection that refers to the given key. If there is more than one matching reference, then the particular reference that is returned is arbitrary

Supported API: false

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 interface: ReferenceBased
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

Supported API: false

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 interface: ReferenceBased
Get all the references used internally by this collection that refers to the given reference. This is used by the default implementation of inflate.

Supported API: false

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

getKeyMask

public int getKeyMask()
Description copied from interface: WTCollection
Returns this collection's key mask. The key mask is a combination of the constants defined in CollectionsHelper.

Supported API: true

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

persistableCollection

public Collection persistableCollection()
Description copied from interface: WTCollection
Provides a Persistable-based view of the objects in this WTCollection. This means the iterator method returns Persistables, and the contains and remove operations only work with Persistable arguments.

The resulting collection is backed by this collection, so changes to one are reflected in the other.

Supported API: true

Specified by:
persistableCollection in interface WTCollection
Overrides:
persistableCollection in class AbstractWTCollection
Returns:
A Collection of Persistables

persistableIterator

public Iterator persistableIterator()
                             throws WTException
Description copied from interface: WTCollection
Returns an iterator over the objects in this collection, as Persistables. Inflates all the QueryKeys and references in this collection that don't have Persistables yet. Persistables that are already in the collection are not refreshed.

Supported API: true

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
Description copied from interface: WTCollection
Refines persistableIterator() to only return objects that are either direct or descendent instances of the filter class, depending on the value of include_subclasses. Implementations should be optimized to return a shared empty iterator instance, if there are no matching objects in this collection.

If a refresh is necessary, implementations should only refresh objects of the given filter class, rather than all the objects in the collection.

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()
Description copied from interface: WTCollection
Returns an iterator over the QueryKeys in this collection. These will typically be ObjectIdentifiers, but may be other QueryKey types depending on how the collection is constructed. Nonpersisted objects will not be included in the id iterator.

Supported API: true

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

queryKeyIterator

public Iterator queryKeyIterator(Class filter,
                                 boolean include_subclasses)
Description copied from interface: WTCollection
Refines queryKeyIterator() to only return keys that are either direct or descendent instances of the filter class, depending on the value of include_subclasses. Implementations should be optimized to return a shared empty iterator instance, if there are no matching objects in this collection.

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()
Description copied from interface: WTCollection
Returns an Iterator over the objects in this collection, as WTReferences. The precise subclass of WTReference is determined by the referenced class, and by this collection's key mask. The references in the iterator may or may not be inflated, depending upon how they were added to the collection and when the collection was last refreshed. Non-persisted objects will still have references in the iterator; they will have null keys.

Supported API: true

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

referenceIterator

public Iterator referenceIterator(Class filter,
                                  boolean include_subclasses)
Description copied from interface: WTCollection
Refines referenceIterator() to only return references that are either direct or descendent instances of the filter class, depending on the value of include_subclasses. Implementations should be optimized to return a shared empty iterator instance, if there are no matching objects in this collection.

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)
Description copied from class: AbstractWTCollection
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(WTReference ref)
Description copied from interface: WTCollection
Removes the object from this collection. See WTCollection.remove(Object) for further documentation. See WTCollection.remove(Object) for further documentation.

Supported API: true

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

remove

public boolean remove(QueryKey id)
Description copied from interface: WTCollection
Removes the object from this collection. See WTCollection.remove(Object) for further documentation. See WTCollection.remove(Object) for further documentation.

Supported API: true

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

removeAll

public boolean removeAll(Class filter,
                         boolean include_subclasses)
Description copied from interface: WTCollection
Removes all objects in this collection that are assignable from the given class.

Supported API: true

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)
Description copied from interface: WTCollection
Removes all objects in this collection that are not assignable from the given class.

Supported API: true

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

size

public int size()
Specified by:
size in interface Collection

subCollection

public WTCollection subCollection(Class filter,
                                  boolean include_subclasses)
Description copied from interface: WTCollection
Returns a sub collection of all the objects in this collection that are either direct or descendent instances of the filter class, depending on the value of include_subclasses. The resulting collection is backed by this collection; modifications to one are reflected in the other. Refreshes to the subcollection should not result in the refresh of the entire collection.

Supported API: true

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