org.apache.ojb.broker.accesslayer
Class PagingIterator

java.lang.Object
  extended by org.apache.ojb.broker.accesslayer.PagingIterator
All Implemented Interfaces:
java.util.Iterator, OJBIterator

public class PagingIterator
extends java.lang.Object
implements OJBIterator

PagingIterator is wrapper around an OJBIterator to support startAt endAt positions. The PagingIterator returns rows including startAt and including endAt. startAt = 1, endAt = 11 returns rows 1 to 11 if available if endAt == Query.NO_END_AT_INDEX endAt is set to the last available row

Version:
$Id: PagingIterator.java 365232 2005-12-21 22:36:07Z tomdz $
Author:
Jakob Braeuchi

Constructor Summary
PagingIterator(OJBIterator anIterator, int startAt, int endAt)
          Constructor
 
Method Summary
 boolean absolute(int row)
          Moves the cursor to the given row number in the iterator.
 void disableLifeCycleEvents()
          Do not fire any PBLifeCycleEvent when reading next item.
 int fullSize()
           
 boolean hasNext()
           
 java.lang.Object next()
           
 boolean relative(int row)
          Moves the cursor a relative number of rows, either positive or negative.
 void releaseDbResources()
          Release all internally used Database resources of the iterator.
 void remove()
          remove is not supported
 int size()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PagingIterator

public PagingIterator(OJBIterator anIterator,
                      int startAt,
                      int endAt)
Constructor

Parameters:
anIterator - wrapped Iterator
startAt - (first row is 1)
endAt - (Query.NO_END_AT_INDEX stands for all available rows)
Method Detail

size

public int size()
         throws PersistenceBrokerException
Specified by:
size in interface OJBIterator
Returns:
the size of the iterator, aka the number of rows in this iterator.
Throws:
PersistenceBrokerException
See Also:
OJBIterator.size()

fullSize

public int fullSize()
             throws PersistenceBrokerException
Specified by:
fullSize in interface OJBIterator
Returns:
the unlimited size of the iterator, fullSize() may differ from size() for PagingIterator
Throws:
PersistenceBrokerException
See Also:
OJBIterator.fullSize()

absolute

public boolean absolute(int row)
                 throws PersistenceBrokerException
Description copied from interface: OJBIterator
Moves the cursor to the given row number in the iterator. If the row number is positive, the cursor moves to the given row number with respect to the beginning of the iterator. The first row is row 1, the second is row 2, and so on.

Specified by:
absolute in interface OJBIterator
Parameters:
row - the row to move to in this iterator, by absolute number
Throws:
PersistenceBrokerException
See Also:
OJBIterator.absolute(int)

relative

public boolean relative(int row)
                 throws PersistenceBrokerException
Description copied from interface: OJBIterator
Moves the cursor a relative number of rows, either positive or negative. Attempting to move beyond the first/last row in the iterator positions the cursor before/after the the first/last row. Calling relative(0) is valid, but does not change the cursor position.

Specified by:
relative in interface OJBIterator
Parameters:
row - the row to move to in this iterator, by relative number
Throws:
PersistenceBrokerException
See Also:
OJBIterator.relative(int)

releaseDbResources

public void releaseDbResources()
Description copied from interface: OJBIterator
Release all internally used Database resources of the iterator. Clients must call this methods explicitely if the iterator is not exhausted by the client application. If the Iterator is exhauseted this method will be called implicitely.

Specified by:
releaseDbResources in interface OJBIterator
See Also:
OJBIterator.releaseDbResources()

remove

public void remove()
remove is not supported

Specified by:
remove in interface java.util.Iterator

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator
See Also:
Iterator.hasNext()

next

public java.lang.Object next()
Specified by:
next in interface java.util.Iterator
See Also:
Iterator.next()

disableLifeCycleEvents

public void disableLifeCycleEvents()
Description copied from interface: OJBIterator
Do not fire any PBLifeCycleEvent when reading next item.

Specified by:
disableLifeCycleEvents in interface OJBIterator
See Also:
OJBIterator.disableLifeCycleEvents()


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30