org.apache.cocoon.components.search
Class LuceneCocoonPager

java.lang.Object
  extended by org.apache.cocoon.components.search.LuceneCocoonPager
All Implemented Interfaces:
Iterator, ListIterator

public class LuceneCocoonPager
extends Object
implements ListIterator

This class should help you to manage paging of hits.

Version:
CVS $Id: LuceneCocoonPager.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Bernhard Huber

Nested Class Summary
static class LuceneCocoonPager.HitWrapper
          A helper class encapsulating found document, and its score
 
Field Summary
static int COUNT_OF_HITS_PER_PAGE_DEFAULT
          Default count of hits per page.
static int HITS_INDEX_START_DEFAULT
          Default starting index
 
Constructor Summary
LuceneCocoonPager()
          Constructor for the LuceneCocoonPager object
LuceneCocoonPager(org.apache.lucene.search.Hits hits)
           
 
Method Summary
 void add(Object o)
          Inserts the specified element into the list (optional operation).
 int getCountOfHits()
          Get count of hits
 int getCountOfHitsPerPage()
          Get count of hits displayed per single page
 int getCountOfPages()
          Caluclate count of pages for displaying all hits
 int getStartIndex()
          Set starting index for retrieving hits
 boolean hasNext()
          Returns true if this list iterator has more elements when traversing the list in the forward direction.
 boolean hasPrevious()
          Returns true if this list iterator has more elements when traversing the list in the reverse direction.
 Object next()
          Returns the next element in the list.
 int nextIndex()
          Returns the index of the element that would be returned by a subsequent call to next.
 Object previous()
          Returns the previous element in the list.
 int previousIndex()
          Returns the index of the element that would be returned by a subsequent call to previous.
 void remove()
          Removes from the list the last element that was returned by next or previous (optional operation).
 void set(Object o)
          Replaces the last element returned by next or previous with the specified element (optional operation).
 void setCountOfHitsPerPage(int countOfHitsPerPage)
          Set count of hits displayed per single page
 void setHits(org.apache.lucene.search.Hits hits)
          Sets the hits attribute of the LuceneCocoonPager object
 void setStartIndex(int start_index)
          Get starting index for retrieving hits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COUNT_OF_HITS_PER_PAGE_DEFAULT

public static final int COUNT_OF_HITS_PER_PAGE_DEFAULT
Default count of hits per page.

See Also:
Constant Field Values

HITS_INDEX_START_DEFAULT

public static final int HITS_INDEX_START_DEFAULT
Default starting index

See Also:
Constant Field Values
Constructor Detail

LuceneCocoonPager

public LuceneCocoonPager(org.apache.lucene.search.Hits hits)
Parameters:
hits - Description of Parameter

LuceneCocoonPager

public LuceneCocoonPager()
Constructor for the LuceneCocoonPager object

Method Detail

setHits

public void setHits(org.apache.lucene.search.Hits hits)
Sets the hits attribute of the LuceneCocoonPager object

Parameters:
hits - The new hits value

setCountOfHitsPerPage

public void setCountOfHitsPerPage(int countOfHitsPerPage)
Set count of hits displayed per single page

Parameters:
countOfHitsPerPage - The new countOfHitsPerPage value

setStartIndex

public void setStartIndex(int start_index)
Get starting index for retrieving hits

Parameters:
start_index - The new startIndex value

set

public void set(Object o)
Replaces the last element returned by next or previous with the specified element (optional operation).

Specified by:
set in interface ListIterator
Parameters:
o - Description of Parameter

getCountOfHits

public int getCountOfHits()
Get count of hits

Returns:
The count of hits

getCountOfHitsPerPage

public int getCountOfHitsPerPage()
Get count of hits displayed per single page

Returns:
The countOfHitsPerPage value

getCountOfPages

public int getCountOfPages()
Caluclate count of pages for displaying all hits

Returns:
The countOfPages value

getStartIndex

public int getStartIndex()
Set starting index for retrieving hits

Returns:
The startIndex value

add

public void add(Object o)
         throws UnsupportedOperationException
Inserts the specified element into the list (optional operation).

Specified by:
add in interface ListIterator
Parameters:
o - Description of Parameter
Throws:
UnsupportedOperationException - Description of Exception

hasNext

public boolean hasNext()
Returns true if this list iterator has more elements when traversing the list in the forward direction.

Specified by:
hasNext in interface Iterator
Specified by:
hasNext in interface ListIterator
Returns:
Description of the Returned Value

hasPrevious

public boolean hasPrevious()
Returns true if this list iterator has more elements when traversing the list in the reverse direction.

Specified by:
hasPrevious in interface ListIterator
Returns:
Description of the Returned Value

next

public Object next()
Returns the next element in the list.

Specified by:
next in interface Iterator
Specified by:
next in interface ListIterator
Returns:
Description of the Returned Value

nextIndex

public int nextIndex()
Returns the index of the element that would be returned by a subsequent call to next.

Specified by:
nextIndex in interface ListIterator
Returns:
Description of the Returned Value

previous

public Object previous()
Returns the previous element in the list.

Specified by:
previous in interface ListIterator
Returns:
Description of the Returned Value

previousIndex

public int previousIndex()
Returns the index of the element that would be returned by a subsequent call to previous.

Specified by:
previousIndex in interface ListIterator
Returns:
Description of the Returned Value

remove

public void remove()
Removes from the list the last element that was returned by next or previous (optional operation).

Specified by:
remove in interface Iterator
Specified by:
remove in interface ListIterator


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.