org.jaffa.persistence.engines.jdbcengine.datasource
Class DataSourceCursor

java.lang.Object
  extended byorg.jaffa.persistence.engines.jdbcengine.datasource.DataSourceCursor
All Implemented Interfaces:
Collection

public class DataSourceCursor
extends Object
implements Collection

This class gives a Collection view of a ResultSet. Each row of the ResultSet is molded into an appropriate Persistent object and added to the Collection. The rows are fetched in groups. The size of each group is determined by the 'hitlistSize' parameter of the init.xml for a particular database definition. On creation, the 1st group of rows are fetched. Use the Iterator (a custom implementation), to fetch all the rows. The Collection interface methods will only on the fetched data. The size() method will return a negative value, unless all the data has been fetched.


Method Summary
 boolean add(Object obj)
          Ensures that this collection contains the specified element.
 boolean addAll(Collection collection)
          Adds all of the elements in the specified collection to this collection.
 void clear()
          Removes all of the elements from this collection.
 boolean contains(Object obj)
          Returns true if this collection contains the specified element.
 boolean containsAll(Collection collection)
          Returns true if this collection contains all of the elements in the specified collection.
 boolean isEmpty()
          Returns true if this collection contains no elements.
 Iterator iterator()
          Returns a custom iterator.
 boolean remove(Object obj)
          Removes a single instance of the specified element from this collection, if it is present.
 boolean removeAll(Collection collection)
          Removes all this collection's elements that are also contained in the specified collection.
 boolean retainAll(Collection collection)
          Retains only the elements in this collection that are contained in the specified collection.
 int size()
          Returns the number of elements in this collection.
 Object[] toArray()
          Returns an array containing all of the elements in this collection.
 Object[] toArray(Object[] obj)
          Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Method Detail

iterator

public Iterator iterator()
Returns a custom iterator. Use the iterator for fetching all the rows.

Specified by:
iterator in interface Collection
Returns:
an iterator over the elements in this collection.

toArray

public Object[] toArray()
Returns an array containing all of the elements in this collection. Note: This will only return the data that has been fetched so far.

Specified by:
toArray in interface Collection
Returns:
an array containing all of the elements in this collection.

addAll

public boolean addAll(Collection collection)
Adds all of the elements in the specified collection to this collection. Note: This will not add any data to the Persistent store.

Specified by:
addAll in interface Collection
Parameters:
collection - elements to be inserted into this collection.
Returns:
true if this collection changed as a result of the call.

containsAll

public boolean containsAll(Collection collection)
Returns true if this collection contains all of the elements in the specified collection. Note: This will only check the data that has been fetched so far.

Specified by:
containsAll in interface Collection
Parameters:
collection - collection to be checked for containment in this collection.
Returns:
true if this collection contains all of the elements in the specified collection.

remove

public boolean remove(Object obj)
Removes a single instance of the specified element from this collection, if it is present. Note: This will not remove any data from the Persistent store. This will only check the data that has been fetched so far.

Specified by:
remove in interface Collection
Parameters:
obj - element to be removed from this collection, if present.
Returns:
true if this collection changed as a result of the call.

add

public boolean add(Object obj)
Ensures that this collection contains the specified element. Note: This will not add any data to the Persistent store.

Specified by:
add in interface Collection
Parameters:
obj - element whose presence in this collection is to be ensured.
Returns:
true if this collection changed as a result of the call.

clear

public void clear()
           throws DataSourceCursorRuntimeException
Removes all of the elements from this collection. Note: This will not have any effect on the Persistent store. This will close the underlying ResultSet.

Specified by:
clear in interface Collection
Throws:
DataSourceCursorRuntimeException - if any error occurs in closing the underlying ResultSet.

contains

public boolean contains(Object obj)
Returns true if this collection contains the specified element. Note: This will only check the data that has been fetched so far.

Specified by:
contains in interface Collection
Parameters:
obj - element whose presence in this collection is to be tested.
Returns:
true if this collection contains the specified element.

toArray

public Object[] toArray(Object[] obj)
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. Note: This will only return the data that has been fetched so far.

Specified by:
toArray in interface Collection
Parameters:
obj - the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
an array containing the elements of this collection.

isEmpty

public boolean isEmpty()
Returns true if this collection contains no elements. However, a 'true' does not mean that there is no more data to be fetched; since it is possible that the fetched elements could have been removed by the remove() methods.

Specified by:
isEmpty in interface Collection
Returns:
true if this collection contains no elements.

removeAll

public boolean removeAll(Collection collection)
Removes all this collection's elements that are also contained in the specified collection. Note: This will not remove any data from the Persistent store. This will only check the data that has been fetched so far.

Specified by:
removeAll in interface Collection
Parameters:
collection - elements to be removed from this collection.
Returns:
true if this collection changed as a result of the call.

retainAll

public boolean retainAll(Collection collection)
Retains only the elements in this collection that are contained in the specified collection. Note: This will not remove any data from the Persistent store. This will only check the data that has been fetched so far.

Specified by:
retainAll in interface Collection
Parameters:
collection - elements to be retained in this collection.
Returns:
true if this collection changed as a result of the call.

size

public int size()
Returns the number of elements in this collection. Note: This will return a negative number, if all the data has not been fetched.

Specified by:
size in interface Collection
Returns:
the number of elements in this collection;


Copyright © 2002-2004 JAFFA Project.