com.xpn.xwiki.plugin.lucene
Class SearchResults
java.lang.Object
com.xpn.xwiki.api.Api
com.xpn.xwiki.plugin.lucene.SearchResults
public class SearchResults
- extends com.xpn.xwiki.api.Api
Container for the results of a search.
This class handles paging through search results and enforces the xwiki rights management by only
returning search results the user executing the search is allowed to view.
- Version:
- $Id: SearchResults.java 24078 2009-09-27 02:37:41Z sdumitriu $
| Fields inherited from class com.xpn.xwiki.api.Api |
context |
|
Constructor Summary |
SearchResults(org.apache.lucene.search.Hits hits,
com.xpn.xwiki.api.XWiki xwiki,
com.xpn.xwiki.XWikiContext context)
|
|
Method Summary |
int |
getEndIndex(java.lang.String beginIndex,
java.lang.String items)
|
int |
getHitcount()
|
int |
getNextIndex(java.lang.String beginIndex,
java.lang.String items)
|
int |
getPreviousIndex(java.lang.String beginIndex,
java.lang.String items)
|
java.util.List |
getResults()
|
java.util.List |
getResults(int beginIndex,
int items)
Returns a list of search results. |
java.util.List |
getResults(java.lang.String beginIndex,
java.lang.String items)
Helper method for use in velocity templates, takes string values instead of ints. |
int |
getTotalHitcount()
|
boolean |
hasNext(java.lang.String beginIndex,
java.lang.String items)
|
boolean |
hasPrevious(java.lang.String beginIndex)
|
| Methods inherited from class com.xpn.xwiki.api.Api |
checkProgrammingRights, convert, convert, getXWikiContext, hasAccessLevel, hasAdminRights, hasProgrammingRights |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SearchResults
public SearchResults(org.apache.lucene.search.Hits hits,
com.xpn.xwiki.api.XWiki xwiki,
com.xpn.xwiki.XWikiContext context)
- Parameters:
hits - Lucene search resultsxwiki - xwiki instance for access rights checking
hasNext
public boolean hasNext(java.lang.String beginIndex,
java.lang.String items)
- Returns:
- true when there are more results than currently displayed.
hasPrevious
public boolean hasPrevious(java.lang.String beginIndex)
- Returns:
- true when there is a page before the one currently displayed, that is, when
beginIndex > 1
getNextIndex
public int getNextIndex(java.lang.String beginIndex,
java.lang.String items)
- Returns:
- the value to be used for the firstIndex URL parameter to build a link pointing to the
next page of results
getPreviousIndex
public int getPreviousIndex(java.lang.String beginIndex,
java.lang.String items)
- Returns:
- the value to be used for the firstIndex URL parameter to build a link pointing to the
previous page of results
getEndIndex
public int getEndIndex(java.lang.String beginIndex,
java.lang.String items)
- Returns:
- the index of the last displayed search result
getResults
public java.util.List getResults(java.lang.String beginIndex,
java.lang.String items)
- Helper method for use in velocity templates, takes string values instead of ints. See
getResults(int,int).
getResults
public java.util.List getResults(int beginIndex,
int items)
- Returns a list of search results. According to beginIndex and endIndex, only a subset of the
results is returned. To get the first ten results, one would use beginIndex=1 and items=10.
- Parameters:
beginIndex - 1-based index of first result to return.items - number of items to return
- Returns:
- List of SearchResult instances starting at
beginIndex and containing
up to items elements.
getResults
public java.util.List getResults()
- Returns:
- all search results in one list.
getHitcount
public int getHitcount()
- Returns:
- total number of searchresults the user is allowed to view
getTotalHitcount
public int getTotalHitcount()
- Returns:
- total number of searchresults including unallowed items
Copyright © 2004-2009 XWiki. All Rights Reserved.