wt.fc.collections
Class CollectionsHelper

java.lang.Object
  extended bywt.fc.collections.CollectionsHelper

public final class CollectionsHelper
extends Object

Provides utility methods for dealing with WTCollections.

Supported API: true

Extendable: false


Field Summary
private static String CLASSNAME
           
static WTCollection EMPTY_COLLECTION
          A reusable empty collection.
(package private) static Iterator EMPTY_ITERATOR
           
static WTKeyedMap EMPTY_KEYED_MAP
          A reusable empty map.
static WTList EMPTY_LIST
          A reusable empty list.
(package private) static ListIterator EMPTY_LIST_ITERATOR
           
(package private) static long[] EMPTY_LONG_ARRAY
           
static WTKeyedMap EMPTY_MAP
          Deprecated. Replaced by EMPTY_KEYED_MAP
(package private) static Object[] EMPTY_OBJECT_ARRAY
           
static WTSet EMPTY_SET
          A reusable empty set.
static WTValuedMap EMPTY_VALUED_MAP
          A reusable empty map.
static CollectionsManager manager
          

Supported API: false
static int OBJECT_IDENTIFIER
          A key mask used to determine what types of QueryKeys and WTReferences can be stored in a WTCollection or WTKeyedMap

Supported API: false
private static String RESOURCE
           
static int VERSION_FOREIGN_KEY
          A key mask used to determine what types of QueryKeys and WTReferences can be stored in a WTCollection or WTKeyedMap

Supported API: false
 
Constructor Summary
CollectionsHelper()
           
 
Method Summary
(package private) static void addElement(WTCollection c, Object o)
          Delegated to by ResultProcessor.addElement implementations
(package private) static void addElement(WTKeyedMap m, Object o)
          Delegated to by ResultProcessor.addElement implementations
static List getExcludedClasses(WTCollection collection, Class base_class)
          Get the list of known subclasses of the given base_class that do not have instances in the given collection.
static WTSet getNonPersistedSubSet(WTCollection collection, boolean connect)
          Get a sub set of the objects in the given collection that are not persisted.
static WTSet getPersistedSubSet(WTCollection collection, boolean connect)
          Get a sub set of the objects in the given collection that are persisted.
static void inflate(WTCollection collection)
          Inflate all elements in the collection that do not have an in-memory copy of their Persistable.
static void inflate(WTCollection collection, RefreshSpec spec)
          Inflate all elements in the collection that do not have an in-memory copy of their Persistable.
static void inflate(WTKeyedMap map)
          Inflate all elements in the map that do not have an in-memory copy of their Persistable.
static void inflate(WTKeyedMap map, RefreshSpec spec)
          Inflate all elements in the map that do not have an in-memory copy of their Persistable, with access control disabled..
static boolean isInflated(WTCollection collection)
          Determine if the given collection contains inflated objects.
static WTCollection synchronizedWTCollection(WTCollection collection)
          

Supported API: true
static WTKeyedMap synchronizedWTKeyedMap(WTKeyedMap map)
          

Supported API: true
static WTList synchronizedWTList(WTList list)
          

Supported API: true
static WTSet synchronizedWTSet(WTSet set)
          

Supported API: true
static WTValuedMap synchronizedWTValuedMap(WTValuedMap map)
          

Supported API: true
static WTCollection unmodifiableWTCollection(WTCollection collection)
          

Supported API: true
static WTKeyedMap unmodifiableWTKeyedMap(WTKeyedMap map)
          

Supported API: true
static WTList unmodifiableWTList(WTList list)
          

Supported API: true
static WTSet unmodifiableWTSet(WTSet set)
          

Supported API: true
static WTValuedMap unmodifiableWTValuedMap(WTValuedMap map)
          

Supported API: true
static void validate(WTCollection collection, Class filter)
          Ensures that all the objects in the given collection are instances of the given filter class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

OBJECT_IDENTIFIER

public static final int OBJECT_IDENTIFIER
A key mask used to determine what types of QueryKeys and WTReferences can be stored in a WTCollection or WTKeyedMap

Supported API: false

See Also:
WTCollection, Constant Field Values

VERSION_FOREIGN_KEY

public static final int VERSION_FOREIGN_KEY
A key mask used to determine what types of QueryKeys and WTReferences can be stored in a WTCollection or WTKeyedMap

Supported API: false

See Also:
WTCollection, Constant Field Values

EMPTY_COLLECTION

public static final WTCollection EMPTY_COLLECTION
A reusable empty collection.

Supported API: false


EMPTY_LIST

public static final WTList EMPTY_LIST
A reusable empty list.

Supported API: false


EMPTY_SET

public static final WTSet EMPTY_SET
A reusable empty set.

Supported API: false


EMPTY_KEYED_MAP

public static final WTKeyedMap EMPTY_KEYED_MAP
A reusable empty map.

Supported API: false


EMPTY_VALUED_MAP

public static final WTValuedMap EMPTY_VALUED_MAP
A reusable empty map.

Supported API: false


manager

public static final CollectionsManager manager


Supported API: false


EMPTY_MAP

public static final WTKeyedMap EMPTY_MAP
Deprecated. Replaced by EMPTY_KEYED_MAP


EMPTY_ITERATOR

static final Iterator EMPTY_ITERATOR

EMPTY_LIST_ITERATOR

static final ListIterator EMPTY_LIST_ITERATOR

EMPTY_OBJECT_ARRAY

static final Object[] EMPTY_OBJECT_ARRAY

EMPTY_LONG_ARRAY

static final long[] EMPTY_LONG_ARRAY
Constructor Detail

CollectionsHelper

public CollectionsHelper()
Method Detail

getExcludedClasses

public static List getExcludedClasses(WTCollection collection,
                                      Class base_class)
                               throws WTException
Get the list of known subclasses of the given base_class that do not have instances in the given collection. This list can then be used to set the excluded descendants on a TableExpression in order to optimize the number of tables a database query needs to hit.

Supported API: true

Parameters:
collection -
base_class -
Returns:
A list of Classes
Throws:
WTException
See Also:
wt.query.AbstractTableExpression#setExcludedDescendants(List)

getNonPersistedSubSet

public static WTSet getNonPersistedSubSet(WTCollection collection,
                                          boolean connect)
Get a sub set of the objects in the given collection that are not persisted. The resulting WTSet is connected to the collection if connect is true. The resulting WTSet is never backed by the collection however -- so additions and removals to one are not reflected in the other.

Supported API: true

Parameters:
collection -
connect -
Returns:
A WTSet containing the non-persisted Persistables in this collection, or EMPTY_SET if there are none.
See Also:
getPersistedSubSet(wt.fc.collections.WTCollection, boolean)

getPersistedSubSet

public static WTSet getPersistedSubSet(WTCollection collection,
                                       boolean connect)
Get a sub set of the objects in the given collection that are persisted. The resulting WTSet is connected to the collection if connect is true. The resulting WTSet is never backed by the collection however -- so additions and removals to one are not reflected in the other.

Supported API: true

Parameters:
collection -
connect -
Returns:
A WTSet containing the persisted Persistables in this collection, or EMPTY_SET if there are none.
See Also:
getNonPersistedSubSet(wt.fc.collections.WTCollection, boolean)

inflate

public static void inflate(WTCollection collection)
                    throws WTException
Inflate all elements in the collection that do not have an in-memory copy of their Persistable. Persistables that are already in the collection are not refreshed.

Supported API: true

Parameters:
collection -
Throws:
WTException

inflate

public static void inflate(WTKeyedMap map)
                    throws WTException
Inflate all elements in the map that do not have an in-memory copy of their Persistable. Persistables that are already in the map are not refreshed. If the map is an instanceof WTValuedMap, then both the keys and the values are inflated.

Supported API: true

Parameters:
map -
Throws:
WTException

inflate

public static void inflate(WTCollection collection,
                           RefreshSpec spec)
                    throws WTException
Inflate all elements in the collection that do not have an in-memory copy of their Persistable. Use the given RefreshSpec to inflate the elements.

Supported API: true

Parameters:
collection -
spec -
Throws:
WTException

inflate

public static void inflate(WTKeyedMap map,
                           RefreshSpec spec)
                    throws WTException
Inflate all elements in the map that do not have an in-memory copy of their Persistable, with access control disabled.. Persistables that are already in the map are not refreshed. If the map is an instanceof WTValuedMap, then both the keys and the values are inflated. se the given RefreshSpec to inflate the elements.

Supported API: true

Parameters:
map -
spec -
Throws:
WTException

isInflated

public static boolean isInflated(WTCollection collection)
Determine if the given collection contains inflated objects. If the collection doesn't contain inflated objects, then calls to persistable-based APIs will require a trip to the server and possibly the database.

Supported API: true

Parameters:
collection -
Returns:
true if this collection doesn't need to be inflated

synchronizedWTCollection

public static WTCollection synchronizedWTCollection(WTCollection collection)


Supported API: true

Parameters:
collection -
Returns:
WTCollection

synchronizedWTKeyedMap

public static WTKeyedMap synchronizedWTKeyedMap(WTKeyedMap map)


Supported API: true

Parameters:
map -
Returns:
WTKeyedMap

synchronizedWTList

public static WTList synchronizedWTList(WTList list)


Supported API: true

Parameters:
list -
Returns:
WTList

synchronizedWTSet

public static WTSet synchronizedWTSet(WTSet set)


Supported API: true

Parameters:
set -
Returns:
WTSet

synchronizedWTValuedMap

public static WTValuedMap synchronizedWTValuedMap(WTValuedMap map)


Supported API: true

Parameters:
map -
Returns:
WTValuedMap

unmodifiableWTCollection

public static WTCollection unmodifiableWTCollection(WTCollection collection)


Supported API: true

Parameters:
collection -
Returns:
WTCollection

unmodifiableWTKeyedMap

public static WTKeyedMap unmodifiableWTKeyedMap(WTKeyedMap map)


Supported API: true

Parameters:
map -
Returns:
WTKeyedMap

unmodifiableWTList

public static WTList unmodifiableWTList(WTList list)


Supported API: true

Parameters:
list -
Returns:
WTList

unmodifiableWTSet

public static WTSet unmodifiableWTSet(WTSet set)


Supported API: true

Parameters:
set -
Returns:
WTSet

unmodifiableWTValuedMap

public static WTValuedMap unmodifiableWTValuedMap(WTValuedMap map)


Supported API: true

Parameters:
map -
Returns:
WTValuedMap

validate

public static void validate(WTCollection collection,
                            Class filter)
Ensures that all the objects in the given collection are instances of the given filter class.

Supported API: true

Parameters:
collection -
filter -
Throws:
ClassCastException - If the filter is not assignable from the class of at least one of the objects in the collection

addElement

static void addElement(WTCollection c,
                       Object o)
Delegated to by ResultProcessor.addElement implementations

Parameters:
c - The WTCollection that is a ResultProcessor
o - The elemetn to add

addElement

static void addElement(WTKeyedMap m,
                       Object o)
Delegated to by ResultProcessor.addElement implementations

Parameters:
m - The WTKeyedMap that is a ResultProcessor
o - The elemetn to add