com.arsdigita.persistence
Interface DataCollection

All Superinterfaces:
DataQuery
All Known Subinterfaces:
DataAssociation, DataAssociationCursor
All Known Implementing Classes:
DataQueryDataCollectionAdapter

public interface DataCollection
extends DataQuery

The DataCollection interface defines the public methods available on a collection of DataObjects. DataCollections can be used to efficiently iterate over a large set of DataObjects and access the values of their properties. A DataCollection has much of the functionality of a DataQuery, and can be filtered or sorted in the same way. A typical usage of a DataCollection is:

   Session ssn = SessionManager.getSession();
   DataCollection employees = ssn.retrieve("com.dotcom.Employee");
   employees.setFilter("name like '%nut'");
   employees.setOrder("name");

   while (employees.next()) {
       System.out.println("ID: " + employees.get("id"),
                          "Name: " + employees.get("id"));
   }
   
A DataCollection can also be used to fetch complete DataObjects as opposed to simply accessing the property values of those DataObjects. This means of access is less efficient than that described above because a Java object must be instantiated for every DataObject in the DataCollection.
   Session ssn = SessionManager.getSession();
   DataCollection employees = ssn.retrieve("com.dotcom.Employee");
   employees.addFilter("name like '%nut'");
   employees.addOrder("name");

   while (employees.next()) {
       DataObject emp = employees.getDataObject();
       System.out.println(emp);
   }
   

Version:
$Revision: #7 $ $Date: 2004/04/07 $
Author:
rhs@mit.edu
See Also:
SessionManager, Session, DataObject, DataQuery

Field Summary
static String versionId
           
 
Method Summary
 boolean contains(DataObject data)
          Tests whether the current collection contains an object.
 boolean contains(OID oid)
          Tests whether the current collection contains an object.
 DataObject getDataObject()
          Returns a data object for the current position in the collection.
 ObjectType getObjectType()
          Returns the object type of the data collection.
 Object getParameter(String parameterName)
          Allows a caller to get a parameter value for a parameter that has already been set
 void setParameter(String parameterName, Object value)
          Allows a user to bind a parameter within a named query.
 
Methods inherited from interface com.arsdigita.persistence.DataQuery
addEqualsFilter, addFilter, addFilter, addInSubqueryFilter, addInSubqueryFilter, addNotEqualsFilter, addNotInSubqueryFilter, addOrder, addOrderWithNull, addPath, alias, clearFilter, clearOrder, close, first, get, getFilterFactory, getPosition, getPropertyValues, getType, hasProperty, isAfterLast, isBeforeFirst, isEmpty, isFirst, isLast, last, next, previous, removeFilter, reset, rewind, setFilter, setOrder, setRange, setRange, setReturnsLowerBound, setReturnsUpperBound, size
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Method Detail

getDataObject

public DataObject getDataObject()
Returns a data object for the current position in the collection.

Returns:
A DataObject.

getObjectType

public ObjectType getObjectType()
Returns the object type of the data collection.

Returns:
The object type of the data collection.

setParameter

public void setParameter(String parameterName,
                         Object value)
Allows a user to bind a parameter within a named query.

Specified by:
setParameter in interface DataQuery
Parameters:
parameterName - The name of the parameter to bind
value - The value to assign to the parameter

getParameter

public Object getParameter(String parameterName)
Allows a caller to get a parameter value for a parameter that has already been set

Specified by:
getParameter in interface DataQuery
Parameters:
parameterName - The name of the parameter to retrieve
Returns:
This returns the object representing the value of the parameter specified by the name or "null" if the parameter value has not yet been set.

contains

public boolean contains(OID oid)
Tests whether the current collection contains an object.

Parameters:
oid - The oid of the object.
Returns:
True if the collection contains the object, false otherwise.

contains

public boolean contains(DataObject data)
Tests whether the current collection contains an object.

Parameters:
data - The dataobject.
Returns:
True if the collection contains the object, false otherwise.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC