Oracle Application Server TopLink API Reference
10g Release 2 (10.1.2)

B15903-01


oracle.toplink.ejb.cmp.wls
Interface CursoredIterator

All Superinterfaces:
java.util.Iterator, java.io.Serializable

public interface CursoredIterator
extends java.io.Serializable, java.util.Iterator

PUBLIC

CursoredIterator provides an interface that conforms to Iterator while providing Cursor behaviour. This interface is returned from an EJB finder method that uses TopLink CursoredStream support. This is TopLink's way of providing cursored support to EJB2.0 finders. Supported methods: close() hasNext() next() next(int) Example: Execute a finder that reads 150 projects. Read the first 50 as singles, then, read the next 50 in bulk. This simulates a screen paging down.


import oracle.toplink.ejb.cmp.wls.*;
import java.util.*;

CursoredIterator cursoredIterator;
ProjectHome projectHome = getProjectHome();

//begin a transaction. Leave this open until done
getTransaction().begin();

System.out.println("Finding multiple Projects...");
Vector projects = new Vector();
cursoredIterator = (CursoredIterator)projectHome.findByNameCursored("proj%").iterator();
for (int index = 0; index < 50; i++) {

Project project = (Project)cursoredIterator.next();
projects.addElement(project);

}
System.out.println("Get the rest all at once ...");
Vector projectsNext50 = cursoredIterator.next(50);
cursoredIterator.close();

//commit transaction, now that we're done
getTransaction().commit();
See Also:
CursoredStream, CursoredCollection

Method Summary
 void close()
           Close the underlying cursor.
 boolean hasNext()
           Answer a boolean indicating if the underlying cursor has more elements to return.
 java.lang.Object next()
           Return the next element from the cursor.
 java.util.Collection next(int numberOfElements)
           Return the next numberOfElements elements in the underlying cursor.
 void remove()
          Remove the last returned entry.

 

Method Detail

close

public void close()

Close the underlying cursor. This should be invoked when the user is finished using the cursor.


hasNext

public boolean hasNext()

Answer a boolean indicating if the underlying cursor has more elements to return.

Specified by:
hasNext in interface java.util.Iterator
Returns:
boolean true if there still remains some object in the result set

next

public java.lang.Object next()

Return the next element from the cursor.

Specified by:
next in interface java.util.Iterator
Returns:
Object The next object in the result set

next

public java.util.Collection next(int numberOfElements)

Return the next numberOfElements elements in the underlying cursor.

Parameters:
numberOfElements - the number of objects to consume from the result set
Returns:
Collection The Collection(Vector) of objects that were consumed from the result set

remove

public void remove()
Remove the last returned entry. (not supported, just here for interface)
Specified by:
remove in interface java.util.Iterator

Copyright © 1998, 2005 Oracle Corporation. All Rights Reserved.