org.apache.ojb.odmg.collections
Class DListImpl

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList
          extended by org.apache.ojb.odmg.collections.DListImpl
All Implemented Interfaces:
Serializable, Iterable, Collection, List, ManageableCollection, PersistenceBrokerAware, DArray, DCollection, DList
Direct Known Subclasses:
DBagImpl

public class DListImpl
extends AbstractList
implements DList, DArray, ManageableCollection, PersistenceBrokerAware

Version:
$Id: DListImpl.java,v 1.1 2007-08-24 22:17:37 ewestfal Exp $
Author:
Thomas Mahler, Armin Waibel
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
DListImpl()
          Used by PB-Kernel to instantiate ManageableCollections FOR INTERNAL USE ONLY
DListImpl(PBKey pbKey)
          Used on odmg-level
 
Method Summary
 void add(int index, Object element)
          Inserts the specified element at the specified position in this list (optional operation).
 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)
           
 DList concat(DList otherList)
          Creates a new DList object that contains the contents of this DList object concatenated with the contents of the otherList object.
 boolean existsElement(String predicate)
          Determines whether there is an element of the collection that evaluates to true for the predicate.
 Object get(int index)
          Returns the element at the specified position in this list.
 List getElements()
          Insert the method's description here.
 Integer getId()
          Lazily return the Id, no point in precomputing it.
protected  Logger getLog()
           
 PBKey getPBKey()
           
protected  TransactionImpl getTransaction()
           
 int hashCode()
           
 Iterator iterator()
          Returns an iterator over the elements in this collection.
 ListIterator listIterator()
          Returns a list iterator of the elements in this list (in proper sequence).
 ListIterator listIterator(int index)
          Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
 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.
 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.
 Object remove(int index)
          Removes the element at the specified position in this list (optional operation).
 void resize(int newSize)
          Resize the array to have newSize elements.
 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)
          Sets the elements.
 void setId(Integer id)
          Sets the id.
 void setPBKey(PBKey pbKey)
           
 int size()
          Returns the number of elements in this collection.
 String toString()
           
 
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, indexOf, lastIndexOf, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, addAll, addAll, clear, contains, containsAll, equals, indexOf, isEmpty, lastIndexOf, remove, removeAll, retainAll, set, subList, toArray, toArray
 

Constructor Detail

DListImpl

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


DListImpl

public DListImpl(PBKey pbKey)
Used on odmg-level

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)

add

public void add(int index,
                Object element)
Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Specified by:
add in interface List
Overrides:
add in class AbstractList
Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
UnsupportedOperationException - if the add method is not supported by this list.
ClassCastException - if the class of the specified element prevents it from being added to this list.
IllegalArgumentException - if some aspect of the specified element prevents it from being added to this list.
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

remove

public Object remove(int index)
Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

This implementation always throws an UnsupportedOperationException.

Specified by:
remove in interface List
Overrides:
remove in class AbstractList
Parameters:
index - the index of the element to remove.
Returns:
the element previously at the specified position.
Throws:
UnsupportedOperationException - if the remove method is not supported by this list.
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

concat

public DList concat(DList otherList)
Creates a new DList object that contains the contents of this DList object concatenated with the contents of the otherList object.

Specified by:
concat in interface DList
Parameters:
otherList - The list whose elements are placed at the end of the list returned by this method.
Returns:
A new DList that is the concatenation of this list and the list referenced by otherList.

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.

get

public Object get(int index)
Returns the element at the specified position in this list.

Specified by:
get in interface List
Specified by:
get in class AbstractList
Parameters:
index - index of element to return.
Returns:
the element at the specified position in this list.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

getElements

public List getElements()
Insert the method's description here. Creation date: (10.02.2001 20:53:01)

Returns:
java.util.Vector

getId

public Integer getId()
Lazily return the Id, no point in precomputing it.

Returns:
int

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 List
Overrides:
iterator in class AbstractList
Returns:
an Iterator over the elements in this collection

listIterator

public ListIterator listIterator()
Returns a list iterator of the elements in this list (in proper sequence).

Specified by:
listIterator in interface List
Overrides:
listIterator in class AbstractList
Returns:
a list iterator of the elements in this list (in proper sequence).

listIterator

public ListIterator listIterator(int index)
Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list. The specified index indicates the first element that would be returned by an initial call to the next method. An initial call to the previous method would return the element with the specified index minus one.

Specified by:
listIterator in interface List
Overrides:
listIterator in class AbstractList
Parameters:
index - index of first element to be returned from the list iterator (by a call to the next method).
Returns:
a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size()).

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.

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface List
Overrides:
hashCode in class AbstractList

toString

public String toString()
Overrides:
toString in class AbstractCollection

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.

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 List
Specified by:
size in class AbstractCollection
Returns:
the number of elements in this collection

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

resize

public void resize(int newSize)
Resize the array to have newSize elements.

Specified by:
resize in interface DArray
Parameters:
newSize - The new size of the array.

setElements

public void setElements(List 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

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.