|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.
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 |
public static final String versionId
Method Detail |
public DataAssociation getDataAssociation()
public DataObject getLink()
public Object getLinkProperty(String name)
name
- The name of the link property.
public void remove()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |