com.arsdigita.persistence
Interface DataAssociationCursor

All Superinterfaces:
DataCollection, DataQuery

public interface DataAssociationCursor
extends DataCollection

DataAssociationCursor - This is used to allow developers to iterate through the objects within an association and get properties for those objects. This does not implement java.util.Iterator because it is a cursor, not an iterator. That is, each row has properties but is not actually an object

This is typically used when the developer wants to iterator through the objects within an association. In the sample of code below, the method gets the cursor from the association, filters the cursor so that it only returns the first N articles and then puts those N articles, into a list to be returned.


 public Collection getArticles(int numberOfArticles) {
     LinkedList articles = new LinkedList();
     DataAssociationCursor cursor = ((DataAssociation) get("articles")).cursor();
     cursor.addFilter(cursor.getFilterFactory().lessThan("rownum",
                                                         numberOfArticles, true));
     while (cursor.next()) {
         articles.addLast(cursor.getDataObject());
     }

     cursor.close();
     return children;
 }

Note that it is important to close the cursor explicitly to return the proper database resources as soon as possible.

Version:
$Revision: #7 $ $Date: 2004/04/07 $
Author:
rhs@mit.edu, randyg@alum.mit.edu

Field Summary
static String versionId
           
 
Method Summary
 DataAssociation getDataAssociation()
          Returns a data association that created this iterator
 DataObject getLink()
          Returns the link associated with the current row.
 Object getLinkProperty(String name)
          Calls get("link." + name).
 void remove()
          Removes the object associated with the current position in the collection.
 
Methods inherited from interface com.arsdigita.persistence.DataCollection
contains, contains, getDataObject, getObjectType, getParameter, setParameter
 
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

getDataAssociation

public DataAssociation getDataAssociation()
Returns a data association that created this iterator


getLink

public DataObject getLink()
Returns the link associated with the current row.

Returns:
The link.

getLinkProperty

public Object getLinkProperty(String name)
Calls get("link." + name).

Parameters:
name - The name of the link property.
Returns:
The property value.

remove

public void remove()
Removes the object associated with the current position in the collection. Note that this has NO EFFECT on the underlying DataAssociation until save() is called on the association's parent DataObject



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