wt.fc.collections
Class AbstractWTCollection

java.lang.Object
  extended byjava.util.AbstractCollection
      extended bywt.fc.collections.AbstractWTCollection
All Implemented Interfaces:
Collection, ReferenceBased, WTCollection
Direct Known Subclasses:
AbstractWTList, WTHashSet, WTKeyedHashMap.KeySet, WTValuedHashMap.AllValues, WTValuedHashMap.FilteredValues

public abstract class AbstractWTCollection
extends AbstractCollection
implements WTCollection, ReferenceBased

Base class for default collection implementations. The add() methods throw UnsupportedOperationExceptions.

Supported API: false

Extendable: false


Nested Class Summary
(package private)  class AbstractWTCollection.PersistableCollection
           
 
Field Summary
private static String CLASSNAME
           
private  WTReference lastReturnedReference
          Non thread-safe reference to last object returned by persistableIterator, queryKeyIterator, referenceIterator.
private  ReferenceMap.IteratorListener listener
          Lazily initialized listener that updates lastReturnedReference when an iterator returns an object
private static String RESOURCE
           
 
Fields inherited from interface wt.fc.collections.WTCollection
DEFLATED_ON_SERIALIZATION
 
Constructor Summary
AbstractWTCollection()
           
 
Method Summary
 boolean add(Object o)
          

Supported API: false
 boolean add(Persistable p)
          

Supported API: false
 boolean add(QueryKey query_key)
          

Supported API: false
 boolean add(WTReference ref)
          

Supported API: false
 boolean addAll(Collection c)
          

Supported API: false
 boolean addAll(QueryResult qr)
          

Supported API: false
abstract  Iterator classIterator()
          

Supported API: false
 boolean connect(Persistable p, WTCollection source)
          

Supported API: false
 boolean connect(Persistable p, WTCollection source, boolean add_if_not_present)
          Connects the given object from the source collection to this collection.
 boolean connect(QueryKey query_key, WTCollection source)
          

Supported API: false
 boolean connect(QueryKey query_key, WTCollection source, boolean add_if_not_present)
          Connects the given object from the source collection to this collection.
(package private) abstract  boolean connect(WTReference r, boolean add)
          Add the reference to the collection's internal data structures
 boolean connect(WTReference ref, WTCollection source)
          

Supported API: false
 boolean connect(WTReference ref, WTCollection source, boolean add_if_not_present)
          Connects the given object from the source collection to this collection.
 boolean connectAll(WTCollection c)
          

Supported API: false
 boolean connectAll(WTCollection source, boolean add_if_not_present)
          Connects the elements in the source collection to this collection.
 boolean contains(Object o)
          

Supported API: false
 boolean contains(Persistable p)
          

Supported API: false
 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 containsOnly(Class filter)
          Determines whether this collection only contains objects that are assignable from the given filter.
 void deflate()
          

Supported API: false
 boolean equals(Object o)
           
(package private)  ReferenceMap.IteratorListener getIteratorListener()
          Lazily initializes sourceCollectionIteratorListener
abstract  int getKeyMask()
          

Supported API: false
protected  WTReference getLastReturnedReference()
          Get a reference to the object last returned by one of the collection's iterators.
 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()
           
 void inflate()
          

Supported API: false
 boolean isDeflatedOnSerialization()
          Gets the value of the attribute: deflatedOnSerialization.
 boolean isEnabled(int mask)
          

Supported API: false
 Iterator iterator()
          

Supported API: false
 Collection persistableCollection()
          Provides a Persistable-based view of the objects in this WTCollection.
abstract  Iterator persistableIterator()
          

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

Supported API: false
abstract  Iterator queryKeyIterator()
          

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

Supported API: false
(package private)  void referenceAdded(WTReference r)
           
abstract  Iterator referenceIterator()
          

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

Supported API: false
(package private)  void referenceRemoved(WTReference r)
           
 boolean remove(Object o)
          

Supported API: false
 boolean remove(Persistable p)
          

Supported API: false
 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.
protected  void setLastReturnedReference(WTReference r)
          Set a reference to the object last returned by one of the collection's iterators.
 WTCollection subCollection(Class filter)
          

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

Supported API: false
 Object[] toArray()
          

Supported API: false
 long[] toArray(long[] array)
          

Supported API: false
 Object[] toArray(Object[] array)
          

Supported API: false
 Persistable[] toArray(Persistable[] array)
          

Supported API: false
 QueryKey[] toArray(QueryKey[] array)
          

Supported API: false
 WTReference[] toArray(WTReference[] array)
          

Supported API: false
 long[] toIdArray()
          

Supported API: false
 
Methods inherited from class java.util.AbstractCollection
clear, containsAll, isEmpty, removeAll, retainAll, size, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
clear, containsAll, isEmpty, removeAll, retainAll, size
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

lastReturnedReference

private transient WTReference lastReturnedReference
Non thread-safe reference to last object returned by persistableIterator, queryKeyIterator, referenceIterator. Used to optimize connect in the common case where one collection is being built by iterating over another


listener

private transient ReferenceMap.IteratorListener listener
Lazily initialized listener that updates lastReturnedReference when an iterator returns an object

Constructor Detail

AbstractWTCollection

public AbstractWTCollection()
Method Detail

isDeflatedOnSerialization

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

Supported API: false

Specified by:
isDeflatedOnSerialization in interface WTCollection
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
Parameters:
a_DeflatedOnSerialization -
Throws:
WTPropertyVetoException

add

public boolean add(Object o)


Supported API: false

Specified by:
add in interface WTCollection
Parameters:
o -
Returns:
boolean

add

public boolean add(Persistable p)


Supported API: false

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

add

public boolean add(QueryKey query_key)


Supported API: false

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

add

public boolean add(WTReference ref)


Supported API: false

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

addAll

public boolean addAll(Collection c)


Supported API: false

Specified by:
addAll in interface WTCollection
Parameters:
c -
Returns:
boolean

addAll

public boolean addAll(QueryResult qr)


Supported API: false

Specified by:
addAll in interface WTCollection
Parameters:
qr -
Returns:
boolean

classIterator

public abstract Iterator classIterator()


Supported API: false

Specified by:
classIterator in interface WTCollection
Returns:
Iterator

connect

public boolean connect(Persistable p,
                       WTCollection source)


Supported API: false

Specified by:
connect in interface WTCollection
Parameters:
p -
source -
Returns:
boolean
See Also:
WTCollection.connect(Persistable,WTCollection,boolean)

connect

public boolean connect(QueryKey query_key,
                       WTCollection source)


Supported API: false

Specified by:
connect in interface WTCollection
Parameters:
query_key -
source -
Returns:
boolean
See Also:
WTCollection.connect(QueryKey,WTCollection,boolean)

connect

public boolean connect(WTReference ref,
                       WTCollection source)


Supported API: false

Specified by:
connect in interface WTCollection
Parameters:
ref -
source -
Returns:
boolean
See Also:
WTCollection.connect(WTReference,WTCollection,boolean)

connectAll

public boolean connectAll(WTCollection c)


Supported API: false

Specified by:
connectAll in interface WTCollection
Parameters:
c -
Returns:
boolean

connect

public boolean connect(Persistable p,
                       WTCollection source,
                       boolean add_if_not_present)
Connects the given object from the source collection to this collection. When the object is inflated or refreshed in the source, it is also inflated or refreshed in this collection, and vice versa. If add_if_not_present is true, then if the object does not exist yet in this collection, it is added to it.

Supported API: false

Specified by:
connect in interface WTCollection
Parameters:
p -
source -
add_if_not_present - When true, the object is added to this collection if it isn't currently contained by it.
Returns:
true If the object was added to the collection
Throws:
IllegalArgumentException - If the source does not have the same key type as this collection
ClassCastException - If this collection does not support connection with the source's implementation of WTCollection.
See Also:
connect(Persistable,WTCollection,boolean)

connect

public boolean connect(QueryKey query_key,
                       WTCollection source,
                       boolean add_if_not_present)
Connects the given object from the source collection to this collection. When the object is inflated or refreshed in the source, it is also inflated or refreshed in this collection, and vice versa. If add_if_not_present is true, then if the object does not exist yet in this collection, it is added to it.

Supported API: false

Specified by:
connect in interface WTCollection
Parameters:
query_key -
source -
add_if_not_present - When true, the object is added to this collection if it isn't currently contained by it.
Returns:
true If this collection was modified by the operation
Throws:
IllegalArgumentException - If the source does not have the same key type as this collection
ClassCastException - If this collection does not support connection with the source's implementation of WTCollection.
See Also:
connect(QueryKey,WTCollection,boolean)

connect

public boolean connect(WTReference ref,
                       WTCollection source,
                       boolean add_if_not_present)
Connects the given object from the source collection to this collection. When the object is inflated or refreshed in the source, it is also inflated or refreshed in this collection, and vice versa. If add_if_not_present is true, then if the object does not exist yet in this collection, it is added to it.

Supported API: false

Specified by:
connect in interface WTCollection
Parameters:
ref -
source -
add_if_not_present - When true, the object is added to this collection if it isn't currently contained by it.
Returns:
true If this collection was modified by the operation
Throws:
IllegalArgumentException - If the source does not have the same key type as this collection
ClassCastException - If this collection does not support connection with the source's implementation of WTCollection.
See Also:
connect(WTReference,WTCollection,boolean)

connectAll

public boolean connectAll(WTCollection source,
                          boolean add_if_not_present)
Connects the elements in the source collection to this collection. When an object is inflated or refreshed in source, it is also inflated or refreshed in this collection, and vice versa. When add_if_not_present is true, all of the objects in the source collection are added to this collection.

Supported API: false

Specified by:
connectAll in interface WTCollection
Parameters:
source -
add_if_not_present - When true, objects in source that aren't currently in this collection are added to this collection.
Returns:
true If the operation modifies this collection.
Throws:
IllegalArgumentException - If connect is true and source does not have the same key type as this collection
ClassCastException - If this collection does not support connection with the source''s implementation of WTCollection.

contains

public boolean contains(Object o)


Supported API: false

Specified by:
contains in interface WTCollection
Parameters:
o -
Returns:
boolean

contains

public boolean contains(Persistable p)


Supported API: false

Specified by:
contains in interface WTCollection
Parameters:
p -
Returns:
boolean

contains

public boolean contains(QueryKey query_key)


Supported API: false

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

contains

public boolean contains(WTReference ref)


Supported API: false

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

containsInstance

public boolean containsInstance(Class filter)


Supported API: false

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

containsNonPersisted

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

Supported API: false

Parameters:
p -
Returns:
true if the collection is modified as a result of this operation

containsOnly

public boolean containsOnly(Class filter)
Determines whether this collection only contains objects that are assignable from the given filter.

Supported API: false

Specified by:
containsOnly in interface WTCollection
Parameters:
filter -
Returns:
boolean

deflate

public void deflate()


Supported API: false

Specified by:
deflate in interface WTCollection

getKeyMask

public abstract int getKeyMask()


Supported API: false

Specified by:
getKeyMask in interface WTCollection
Returns:
int
See Also:
CollectionsHelper.OBJECT_IDENTIFIER, CollectionsHelper.VERSION_FOREIGN_KEY

inflate

public void inflate()
             throws WTException


Supported API: false

Specified by:
inflate in interface WTCollection
Throws:
WTException

isEnabled

public boolean isEnabled(int mask)


Supported API: false

Specified by:
isEnabled in interface WTCollection
Parameters:
mask -
Returns:
boolean
See Also:
WTCollection.getKeyMask()

iterator

public Iterator iterator()


Supported API: false

Specified by:
iterator in interface WTCollection
Returns:
Iterator

persistableCollection

public Collection persistableCollection()
Provides a Persistable-based view of the objects in this WTCollection. This means the iterator method returns Persistables, and the add, 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: false

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

persistableIterator

public abstract Iterator persistableIterator()
                                      throws WTException


Supported API: false

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

persistableIterator

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


Supported API: false

Specified by:
persistableIterator in interface WTCollection
Parameters:
filter -
include_subclasses -
Returns:
Iterator
Throws:
WTException
See Also:
WTCollection.persistableIterator()

queryKeyIterator

public abstract Iterator queryKeyIterator()


Supported API: false

Specified by:
queryKeyIterator in interface WTCollection
Returns:
Iterator

queryKeyIterator

public abstract Iterator queryKeyIterator(Class filter,
                                          boolean include_subclasses)


Supported API: false

Specified by:
queryKeyIterator in interface WTCollection
Parameters:
filter -
include_subclasses -
Returns:
Iterator
See Also:
WTCollection.queryKeyIterator()

referenceIterator

public abstract Iterator referenceIterator()


Supported API: false

Specified by:
referenceIterator in interface WTCollection
Returns:
Iterator

referenceIterator

public abstract Iterator referenceIterator(Class filter,
                                           boolean include_subclasses)


Supported API: false

Specified by:
referenceIterator in interface WTCollection
Parameters:
filter -
include_subclasses -
Returns:
Iterator
See Also:
WTCollection.queryKeyIterator()

remove

public boolean remove(Object o)


Supported API: false

Specified by:
remove in interface WTCollection
Parameters:
o -
Returns:
boolean

remove

public boolean remove(Persistable p)


Supported API: false

Specified by:
remove in interface WTCollection
Parameters:
p -
Returns:
boolean

removeNonPersisted

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

Supported API: false

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
Parameters:
query_key -
Returns:
boolean

remove

public boolean remove(WTReference ref)


Supported API: false

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

removeAll

public boolean removeAll(Class filter,
                         boolean include_subclasses)


Supported API: false

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

retainAll

public boolean retainAll(Class filter,
                         boolean include_subclasses)


Supported API: false

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

subCollection

public WTCollection subCollection(Class filter)


Supported API: false

Specified by:
subCollection in interface WTCollection
Parameters:
filter -
Returns:
WTCollection

subCollection

public abstract WTCollection subCollection(Class filter,
                                           boolean include_subclasses)


Supported API: false

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

toArray

public Object[] toArray()


Supported API: false

Specified by:
toArray in interface WTCollection
Returns:
Object[]

toArray

public Object[] toArray(Object[] array)


Supported API: false

Specified by:
toArray in interface WTCollection
Parameters:
array -
Returns:
Object[]

toArray

public Persistable[] toArray(Persistable[] array)


Supported API: false

Specified by:
toArray in interface WTCollection
Parameters:
array -
Returns:
Persistable[]

toArray

public QueryKey[] toArray(QueryKey[] array)


Supported API: false

Specified by:
toArray in interface WTCollection
Parameters:
array -
Returns:
QueryKey[]

toArray

public WTReference[] toArray(WTReference[] array)


Supported API: false

Specified by:
toArray in interface WTCollection
Parameters:
array -
Returns:
WTReference[]

toArray

public long[] toArray(long[] array)


Supported API: false

Specified by:
toArray in interface WTCollection
Parameters:
array -
Returns:
long[]

toIdArray

public long[] toIdArray()


Supported API: false

Specified by:
toIdArray in interface WTCollection
Returns:
long[]

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection

hashCode

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

getReference

public WTReference getReference(Persistable p)
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
Parameters:
p -
Returns:
WTReference The reference or null

getReference

public WTReference getReference(QueryKey q)
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
Parameters:
q -
Returns:
WTReference The reference or null

getReference

public WTReference getReference(WTReference r)
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
Parameters:
r -
Returns:
WTReference The reference or null

getReferences

public WTReference[] getReferences(WTReference r)
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
Parameters:
r -
Returns:
WTReference The reference or null

referenceAdded

void referenceAdded(WTReference r)

referenceRemoved

void referenceRemoved(WTReference r)

connect

abstract boolean connect(WTReference r,
                         boolean add)
Add the reference to the collection's internal data structures


getLastReturnedReference

protected WTReference getLastReturnedReference()
Get a reference to the object last returned by one of the collection's iterators. It is up to implementation classes to set this value. By setting this value, connect() may be able to avoid iterating through the entire collection in the common case where one collection is built by connect references from another.

Returns:
WTReference

setLastReturnedReference

protected void setLastReturnedReference(WTReference r)
Set a reference to the object last returned by one of the collection's iterators. It is up to implementation classes to set this value. By setting this value, connect() may be able to avoid iterating through the entire collection in the common case where one collection is built by connect references from another.

Parameters:
r -

getIteratorListener

ReferenceMap.IteratorListener getIteratorListener()
Lazily initializes sourceCollectionIteratorListener