com.sun.mdm.index.page
Class PageIterator

java.lang.Object
  extended bycom.sun.mdm.index.page.PageIterator
All Implemented Interfaces:
java.io.Serializable

public class PageIterator
extends java.lang.Object
implements java.io.Serializable

Used by paging mechanism to efficiently transport data to caller in pages.

See Also:
Serialized Form

Constructor Summary
PageIterator(java.util.List fullData)
          Constructor where data is passed to client directly
PageIterator(java.lang.Object[] fullData)
          Constructor where data is passed to client directly
PageIterator(PageData pageData, int pageSize, int maxElements)
          Constructor where data is stored on the server
 
Method Summary
 java.lang.Object absolute(int index)
          Returns the element at the specified index.
 java.util.ArrayList absolute(int index, int count)
          Returns the next 'count' elements beginning with the element at the specified index.
 void close()
          Free the server side resources.
 int count()
          Returns the number of records in the iterator.
 int currentPosition()
          Returns the current position of the iterator.
 java.lang.Object first()
          Get the first record in the iterator.
 java.util.ArrayList first(int count)
          Get the first 'count' records in the iterator or however many records are left if 'count' is greater than the size of the iterator.
 boolean hasNext()
          Returns true if there are more records left in the iterator.
 java.lang.Object next()
          Returns next element.
 java.util.ArrayList next(int count)
          Get next 'count' number of elements.
 java.lang.Object prev()
          Get previous element.
 java.util.ArrayList prev(int count)
          Get 'count' previous elements.
 void setReadForwardOnly(boolean forwardOnly)
          Set the forward only mode that will clear all the DataPage objects of of a given loaded page i when we start reading/loading the next page i+1.
 void sortBy(java.util.Comparator c)
          Sort the objects based on the comparator
 void sortSummaryBy(java.util.Comparator c)
          Sort the objects based on the comparator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PageIterator

public PageIterator(java.util.List fullData)
Constructor where data is passed to client directly

Parameters:
fullData - list of all objects

PageIterator

public PageIterator(java.lang.Object[] fullData)
Constructor where data is passed to client directly

Parameters:
fullData - array of all objects of result set

PageIterator

public PageIterator(PageData pageData,
                    int pageSize,
                    int maxElements)
Constructor where data is stored on the server

Parameters:
pageData - session bean storing data
pageSize - unit size of data retrieval from server
maxElements - maximum elements that will be retrieved
Method Detail

absolute

public java.lang.Object absolute(int index)
                          throws PageException,
                                 java.rmi.RemoteException
Returns the element at the specified index.

Parameters:
index - row to retrieve
Returns:
Object at index
Throws:
PageException - An error occured.
java.rmi.RemoteException - An error occured.

absolute

public java.util.ArrayList absolute(int index,
                                    int count)
                             throws PageException,
                                    java.rmi.RemoteException
Returns the next 'count' elements beginning with the element at the specified index.

Parameters:
index - Row to retrieve.
count - Number of elements to retrieve.
Returns:
List of objects beginning at index
Throws:
PageException - An error occured.
java.rmi.RemoteException - An error occured.

close

public void close()
           throws java.rmi.RemoteException
Free the server side resources.

Throws:
java.rmi.RemoteException - An error occured.

count

public int count()
          throws PageException,
                 java.rmi.RemoteException
Returns the number of records in the iterator.

Returns:
number of records in the iterator
Throws:
PageException - An error occured.
java.rmi.RemoteException - An error occured.

currentPosition

public int currentPosition()
Returns the current position of the iterator. The position of the iterator can be from (-1) to (recordCount - 1).

Returns:
Current position

first

public java.lang.Object first()
                       throws PageException,
                              java.rmi.RemoteException
Get the first record in the iterator.

Returns:
First Object
Throws:
PageException - An error occured.
java.rmi.RemoteException - An error occured.

first

public java.util.ArrayList first(int count)
                          throws PageException,
                                 java.rmi.RemoteException
Get the first 'count' records in the iterator or however many records are left if 'count' is greater than the size of the iterator.

Parameters:
count - Number of records to retrieve
Returns:
List of first 'count' records
Throws:
PageException - An error occured.
java.rmi.RemoteException - An error occured.

hasNext

public boolean hasNext()
                throws java.rmi.RemoteException,
                       PageException
Returns true if there are more records left in the iterator.

Returns:
true if there are more records
Throws:
java.rmi.RemoteException - An error occured.
PageException - An error occured.

next

public java.lang.Object next()
                      throws java.rmi.RemoteException,
                             PageException
Returns next element. Throws PageException if hasNext() is false. Note that if current index=4, next() will return element at index=4.

Returns:
Next element
Throws:
java.rmi.RemoteException - An error occured.
PageException - An error occured.

next

public java.util.ArrayList next(int count)
                         throws java.rmi.RemoteException,
                                PageException
Get next 'count' number of elements. If less than count number of elements left only return as many as are left. If already at end of iterator throw PageException.

Parameters:
count - Number of objects to retrieve
Returns:
List of next 'count' elements.
Throws:
java.rmi.RemoteException - An error occured.
PageException - An error occured.

prev

public java.lang.Object prev()
                      throws PageException,
                             java.rmi.RemoteException
Get previous element. If already at beginning of iterator, throws PageException. Note that if current position is index=5, prev() will return element at index=4 and leave the current position at index=4.

Returns:
Previous element
Throws:
PageException - An error occured.
java.rmi.RemoteException - An error occured.

prev

public java.util.ArrayList prev(int count)
                         throws PageException,
                                java.rmi.RemoteException
Get 'count' previous elements.

Parameters:
count - Number of objects to retrieve
Returns:
List of objects
Throws:
PageException - An error occured.
java.rmi.RemoteException - An error occured.

setReadForwardOnly

public void setReadForwardOnly(boolean forwardOnly)
Set the forward only mode that will clear all the DataPage objects of of a given loaded page i when we start reading/loading the next page i+1.

Parameters:
forwardOnly - the

sortBy

public void sortBy(java.util.Comparator c)
            throws java.rmi.RemoteException,
                   PageException
Sort the objects based on the comparator

Parameters:
c - Comparator to sort by
Throws:
PageException - An error occured.
java.rmi.RemoteException - An error occured.

sortSummaryBy

public void sortSummaryBy(java.util.Comparator c)
                   throws java.rmi.RemoteException,
                          PageException
Sort the objects based on the comparator

Parameters:
c - Comparator to sort by
Throws:
PageException - An error occured.
java.rmi.RemoteException - An error occured.


Sun Microsystems, Inc.