org.hippoecm.hst.content.beans.standard
Interface HippoBeanIterator

All Superinterfaces:
Iterator<HippoBean>
All Known Implementing Classes:
HippoBeanIteratorImpl, MockHippoBeanIterator

public interface HippoBeanIterator
extends Iterator<HippoBean>

A lazy proxied iterator, that only fetches the next bean when asked for it. As we fetch the beans lazily, this iterator is very efficient. For performance reasons, it is really important to use skip(int skipNum) if you know where you would like to start iterating from.


Method Summary
 long getPosition()
          Returns the current position within the iterator.
 long getSize()
          Returns the number of elements in the iterator.
 HippoBean nextHippoBean()
          Returns the next HippoBean in the iteration.
 void skip(int skipNum)
          Skip a number of elements in the iterator.
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Method Detail

nextHippoBean

HippoBean nextHippoBean()
Returns the next HippoBean in the iteration. Note this method is allowed to return null when the backing jcr node cannot be mapped to a HippoBean.

Returns:
the next HippoBean in the iteration or null if the jcr node cannot be mapped to a HippoBean
Throws:
NoSuchElementException - if iteration has no more HippoBeans.

skip

void skip(int skipNum)
Skip a number of elements in the iterator. Using skip is very efficient when you know you want to have the, say, 100 to 110 beans, as the skip does not need to fetch number 1 to 100.

Parameters:
skipNum - the non-negative number of elements to skip
Throws:
NoSuchElementException - if skipped past the last element in the iterator.

getSize

long getSize()
Returns the number of elements in the iterator. If this information is unavailable, returns -1.

Returns:
a long

getPosition

long getPosition()
Returns the current position within the iterator. The number returned is the 0-based index of the next element in the iterator, i.e. the one that will be returned on the subsequent next call.

Note that this method does not check if there is a next element, i.e. an empty iterator will always return 0.

Returns:
a long


Copyright © 2008-2012 Hippo. All Rights Reserved.