org.apache.ojb.odmg.collections
Class DSetImpl

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet
          extended by org.apache.ojb.odmg.collections.DSetImpl
All Implemented Interfaces:
Serializable, Iterable, Collection, Set, ManageableCollection, PersistenceBrokerAware, DCollection, DSet

public class DSetImpl
extends AbstractSet
implements DSet, Serializable, PersistenceBrokerAware, ManageableCollection

See Also:
Serialized Form

Constructor Summary
DSetImpl()
          Used by PB-Kernel to instantiate ManageableCollections FOR INTERNAL USE ONLY
DSetImpl(PBKey pbKey)
          DSetImpl constructor comment.
 
Method Summary
 boolean add(Object o)
           
 void afterDelete(PersistenceBroker broker)
          noop
 void afterInsert(PersistenceBroker broker)
          noop
 void afterLookup(PersistenceBroker broker)
          noop
 void afterStore(PersistenceBroker broker)
          A callback method to implement 'removal-aware' (track removed objects and delete them by its own) collection implementations.
 void afterUpdate(PersistenceBroker broker)
          noop
 void beforeDelete(PersistenceBroker broker)
          noop
 void beforeInsert(PersistenceBroker broker)
          prepare itself for persistence.
 void beforeUpdate(PersistenceBroker broker)
          noop
protected  boolean checkForOpenTransaction(TransactionImpl tx)
           
 DSet difference(DSet otherSet)
          Create a new DSet object that contains the elements of this collection minus the elements in otherSet.
 boolean existsElement(String predicate)
          Determines whether there is an element of the collection that evaluates to true for the predicate.
 List getElements()
           
 Integer getId()
           
protected  Logger getLog()
           
 PBKey getPBKey()
           
protected  TransactionImpl getTransaction()
           
 DSet intersection(DSet otherSet)
          Create a new DSet object that is the set intersection of this DSet object and the set referenced by otherSet.
 Iterator iterator()
          Returns an iterator over the elements in this collection.
 void ojbAdd(Object anObject)
          add a single Object to the Collection.
 void ojbAddAll(ManageableCollection otherCollection)
          adds a Collection to this collection.
 Iterator ojbIterator()
          returns an Iterator over all elements in the collection.
 boolean properSubsetOf(DSet otherSet)
          Determine whether this set is a proper subset of the set referenced by otherSet.
 boolean properSupersetOf(DSet otherSet)
          Determine whether this set is a proper superset of the set referenced by otherSet.
 DCollection query(String predicate)
          Evaluate the boolean query predicate for each element of the collection and return a new collection that contains each element that evaluated to true.
 boolean remove(Object o)
           
 boolean removeAll(Collection c)
           
 Iterator select(String predicate)
          Access all of the elements of the collection that evaluate to true for the provided query predicate.
 Object selectElement(String predicate)
          Selects the single element of the collection for which the provided OQL query predicate is true.
 void setElements(List elements)
           
 void setElements(Vector elements)
          Sets the elements.
 void setId(Integer id)
          Sets the id.
 void setPBKey(PBKey pbKey)
           
 int size()
          Returns the number of elements in this collection.
 boolean subsetOf(DSet otherSet)
          Determine whether this set is a subset of the set referenced by otherSet.
 boolean supersetOf(DSet otherSet)
          Determine whether this set is a superset of the set referenced by otherSet.
 DSet union(DSet otherSet)
          Create a new DSet object that is the set union of this DSet object and the set referenced by otherSet.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode
 
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, retainAll, toArray, 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, clear, contains, containsAll, equals, hashCode, isEmpty, retainAll, toArray, toArray
 

Constructor Detail

DSetImpl

public DSetImpl()
Used by PB-Kernel to instantiate ManageableCollections FOR INTERNAL USE ONLY


DSetImpl

public DSetImpl(PBKey pbKey)
DSetImpl constructor comment.

Method Detail

getLog

protected Logger getLog()

getTransaction

protected TransactionImpl getTransaction()

checkForOpenTransaction

protected boolean checkForOpenTransaction(TransactionImpl tx)

getPBKey

public PBKey getPBKey()

setPBKey

public void setPBKey(PBKey pbKey)

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection
Specified by:
remove in interface Set
Overrides:
remove in class AbstractCollection

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface Collection
Specified by:
removeAll in interface Set
Overrides:
removeAll in class AbstractSet

add

public boolean add(Object o)
Specified by:
add in interface Collection
Specified by:
add in interface Set
Overrides:
add in class AbstractCollection

difference

public DSet difference(DSet otherSet)
Create a new DSet object that contains the elements of this collection minus the elements in otherSet.

Specified by:
difference in interface DSet
Parameters:
otherSet - A set containing elements that should not be in the result set.
Returns:
A newly created DSet instance that contains the elements of this set minus those elements in otherSet.

existsElement

public boolean existsElement(String predicate)
                      throws QueryInvalidException
Determines whether there is an element of the collection that evaluates to true for the predicate.

Specified by:
existsElement in interface DCollection
Parameters:
predicate - An OQL boolean query predicate.
Returns:
True if there is an element of the collection that evaluates to true for the predicate, otherwise false.
Throws:
QueryInvalidException - The query predicate is invalid.

getElements

public List getElements()

setElements

public void setElements(List elements)

getId

public Integer getId()

intersection

public DSet intersection(DSet otherSet)
Create a new DSet object that is the set intersection of this DSet object and the set referenced by otherSet.

Specified by:
intersection in interface DSet
Parameters:
otherSet - The other set to be used in the intersection operation.
Returns:
A newly created DSet instance that contains the intersection of the two sets.

iterator

public Iterator iterator()
Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee).

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface Set
Specified by:
iterator in class AbstractCollection
Returns:
an Iterator over the elements in this collection

properSubsetOf

public boolean properSubsetOf(DSet otherSet)
Determine whether this set is a proper subset of the set referenced by otherSet.

Specified by:
properSubsetOf in interface DSet
Parameters:
otherSet - Another set.
Returns:
True if this set is a proper subset of the set referenced by otherSet, otherwise false.

properSupersetOf

public boolean properSupersetOf(DSet otherSet)
Determine whether this set is a proper superset of the set referenced by otherSet.

Specified by:
properSupersetOf in interface DSet
Parameters:
otherSet - Another set.
Returns:
True if this set is a proper superset of the set referenced by otherSet, otherwise false.

query

public DCollection query(String predicate)
                  throws QueryInvalidException
Evaluate the boolean query predicate for each element of the collection and return a new collection that contains each element that evaluated to true.

Specified by:
query in interface DCollection
Parameters:
predicate - An OQL boolean query predicate.
Returns:
A new collection containing the elements that evaluated true for the predicate.
Throws:
QueryInvalidException - The query predicate is invalid.

select

public Iterator select(String predicate)
                throws QueryInvalidException
Access all of the elements of the collection that evaluate to true for the provided query predicate.

Specified by:
select in interface DCollection
Parameters:
predicate - An OQL boolean query predicate.
Returns:
An iterator used to iterate over the elements that evaluated true for the predicate.
Throws:
QueryInvalidException - The query predicate is invalid.

selectElement

public Object selectElement(String predicate)
                     throws QueryInvalidException
Selects the single element of the collection for which the provided OQL query predicate is true.

Specified by:
selectElement in interface DCollection
Parameters:
predicate - An OQL boolean query predicate.
Returns:
The element that evaluates to true for the predicate. If no element evaluates to true, null is returned.
Throws:
QueryInvalidException - The query predicate is invalid.

setElements

public void setElements(Vector elements)
Sets the elements.

Parameters:
elements - The elements to set

setId

public void setId(Integer id)
Sets the id.

Parameters:
id - The id to set

size

public int size()
Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Specified by:
size in interface Collection
Specified by:
size in interface Set
Specified by:
size in class AbstractCollection
Returns:
the number of elements in this collection

subsetOf

public boolean subsetOf(DSet otherSet)
Determine whether this set is a subset of the set referenced by otherSet.

Specified by:
subsetOf in interface DSet
Parameters:
otherSet - Another set.
Returns:
True if this set is a subset of the set referenced by otherSet, otherwise false.

supersetOf

public boolean supersetOf(DSet otherSet)
Determine whether this set is a superset of the set referenced by otherSet.

Specified by:
supersetOf in interface DSet
Parameters:
otherSet - Another set.
Returns:
True if this set is a superset of the set referenced by otherSet, otherwise false.

union

public DSet union(DSet otherSet)
Create a new DSet object that is the set union of this DSet object and the set referenced by otherSet.

Specified by:
union in interface DSet
Parameters:
otherSet - The other set to be used in the union operation.
Returns:
A newly created DSet instance that contains the union of the two sets.

ojbAdd

public void ojbAdd(Object anObject)
add a single Object to the Collection. This method is used during reading Collection elements from the database. Thus it is is save to cast anObject to the underlying element type of the collection.

Specified by:
ojbAdd in interface ManageableCollection
Parameters:
anObject - The object to add

ojbAddAll

public void ojbAddAll(ManageableCollection otherCollection)
adds a Collection to this collection. Used in reading Extents from the Database. Thus it is save to cast otherCollection to this.getClass().

Specified by:
ojbAddAll in interface ManageableCollection
Parameters:
otherCollection - The added collection

afterStore

public void afterStore(PersistenceBroker broker)
                throws PersistenceBrokerException
Description copied from interface: ManageableCollection
A callback method to implement 'removal-aware' (track removed objects and delete them by its own) collection implementations.

Specified by:
afterStore in interface ManageableCollection
Parameters:
broker - The persistence broker
Throws:
PersistenceBrokerException

ojbIterator

public Iterator ojbIterator()
returns an Iterator over all elements in the collection. Used during store and delete Operations. If the implementor does not return an iterator over ALL elements, OJB cannot store and delete all elements properly.

Specified by:
ojbIterator in interface ManageableCollection
Returns:
The iterator

beforeInsert

public void beforeInsert(PersistenceBroker broker)
                  throws PersistenceBrokerException
prepare itself for persistence. Each DList entry generates an Identity for the wrapped persistent object.

Specified by:
beforeInsert in interface PersistenceBrokerAware
Parameters:
broker - The persistence broker performing the persistence operation
Throws:
PersistenceBrokerException

beforeUpdate

public void beforeUpdate(PersistenceBroker broker)
                  throws PersistenceBrokerException
noop

Specified by:
beforeUpdate in interface PersistenceBrokerAware
Parameters:
broker - The persistence broker performing the persistence operation
Throws:
PersistenceBrokerException

beforeDelete

public void beforeDelete(PersistenceBroker broker)
                  throws PersistenceBrokerException
noop

Specified by:
beforeDelete in interface PersistenceBrokerAware
Parameters:
broker - The persistence broker performing the persistence operation
Throws:
PersistenceBrokerException

afterUpdate

public void afterUpdate(PersistenceBroker broker)
                 throws PersistenceBrokerException
noop

Specified by:
afterUpdate in interface PersistenceBrokerAware
Parameters:
broker - The persistence broker performed the persistence operation
Throws:
PersistenceBrokerException

afterInsert

public void afterInsert(PersistenceBroker broker)
                 throws PersistenceBrokerException
noop

Specified by:
afterInsert in interface PersistenceBrokerAware
Parameters:
broker - The persistence broker performing the persistence operation
Throws:
PersistenceBrokerException

afterDelete

public void afterDelete(PersistenceBroker broker)
                 throws PersistenceBrokerException
noop

Specified by:
afterDelete in interface PersistenceBrokerAware
Parameters:
broker - The persistence broker performing the persistence operation
Throws:
PersistenceBrokerException

afterLookup

public void afterLookup(PersistenceBroker broker)
                 throws PersistenceBrokerException
noop

Specified by:
afterLookup in interface PersistenceBrokerAware
Parameters:
broker - The persistence broker performing the persistence operation
Throws:
PersistenceBrokerException


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.