com.atlassian.user.search.page
Class AbstractPrefetchingPager<T>

java.lang.Object
  extended by com.atlassian.user.search.page.AbstractPrefetchingPager<T>
All Implemented Interfaces:
Pager<T>, Iterable<T>, Iterator<T>
Direct Known Subclasses:
AbstractLDAPPager

public abstract class AbstractPrefetchingPager<T>
extends Object
implements Pager<T>, Iterator<T>


Field Summary
protected  int idx
           
protected  int indexOfFirstItemInCurrentPage
           
 boolean lastPage
           
static org.apache.log4j.Category log
           
 
Fields inherited from interface com.atlassian.user.search.page.Pager
EMPTY_PAGER, NO_POSITION, PRELOAD_LIMIT
 
Constructor Summary
AbstractPrefetchingPager()
           
 
Method Summary
protected abstract  List<T> fetch(Object element, List<T> prefetched)
           
 List<T> getCurrentPage()
           
 int getIndex()
           
 int getIndexOfFirstItemInCurrentPage()
           
protected  int getIndexWithinPage()
           
 boolean hasNext()
           
 boolean isEmpty()
           
 Iterator<T> iterator()
          Use this if you want a typical iterator over the entire data.
 T next()
           
 void nextPage()
           
 boolean onLastPage()
           
protected abstract  void preload()
           
protected  void preload(Iterator iterator)
           
 void remove()
           
 void skipTo(int idx)
          Will run the index up to this point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Category log

idx

protected int idx

indexOfFirstItemInCurrentPage

protected int indexOfFirstItemInCurrentPage

lastPage

public boolean lastPage
Constructor Detail

AbstractPrefetchingPager

public AbstractPrefetchingPager()
Method Detail

iterator

public Iterator<T> iterator()
Description copied from interface: Pager
Use this if you want a typical iterator over the entire data.

Specified by:
iterator in interface Pager<T>
Specified by:
iterator in interface Iterable<T>
Returns:
an Iterator for the entire result set.

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Pager<T>

getCurrentPage

public List<T> getCurrentPage()
Specified by:
getCurrentPage in interface Pager<T>
Returns:
a single, preloaded page.

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<T>

preload

protected abstract void preload()

remove

public void remove()
Specified by:
remove in interface Iterator<T>

preload

protected void preload(Iterator iterator)

fetch

protected abstract List<T> fetch(Object element,
                                 List<T> prefetched)
                          throws EntityException
Throws:
EntityException

nextPage

public void nextPage()
Specified by:
nextPage in interface Pager<T>

getIndex

public int getIndex()
Specified by:
getIndex in interface Pager<T>
Returns:
the current index position of the pager

skipTo

public void skipTo(int idx)
            throws PagerException
Description copied from interface: Pager
Will run the index up to this point. Calling Pager.getCurrentPage() will then return a page holding this index.

Specified by:
skipTo in interface Pager<T>
Parameters:
idx - the zero-based index of the item to skip to.
Throws:
PagerException - - if the number of items in the backing data is exceeded by the index.

onLastPage

public boolean onLastPage()
Specified by:
onLastPage in interface Pager<T>

getIndexOfFirstItemInCurrentPage

public int getIndexOfFirstItemInCurrentPage()
Specified by:
getIndexOfFirstItemInCurrentPage in interface Pager<T>
Returns:
the index of the first item in the current page, relative to the start of the set

next

public T next()
Specified by:
next in interface Iterator<T>

getIndexWithinPage

protected int getIndexWithinPage()


Copyright © 2005-2009 Atlassian Software Systems Pty Ltd. All Rights Reserved.