com.day.cq.search.impl.result
Class SearchResultImpl

java.lang.Object
  extended by com.day.cq.search.impl.result.SearchResultImpl
All Implemented Interfaces:
SearchResult

public class SearchResultImpl
extends Object
implements SearchResult

SearchResult exposes the JCR query result in a scripting friendly way.


Constructor Summary
SearchResultImpl(QueryImpl query, RowIterator rows, long executionTime, long startIndex, long hitsPerPage)
          Creates a new query result.
 
Method Summary
 String getExecutionTime()
          Returns the execution time in fractions of a second.
 long getExecutionTimeMillis()
          Returns the execution time in milliseconds.
 Map<String,Facet> getFacets()
          Returns the facets for this search result.
 String getFilteringPredicates()
          Returns a string with a list of the predicates that were filtering the result set (as opposed to using XPath, see SearchResult.getQueryStatement()).
 List<Hit> getHits()
           
 long getHitsPerPage()
           
 ResultPage getNextPage()
           
 ResultPage getPreviousPage()
           
 String getQueryStatement()
          Returns the actual query string run against the repository, eg.
 List<ResultPage> getResultPages()
           
 long getStartIndex()
           
 long getTotalMatches()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchResultImpl

public SearchResultImpl(QueryImpl query,
                        RowIterator rows,
                        long executionTime,
                        long startIndex,
                        long hitsPerPage)
Creates a new query result.

Parameters:
query - the query object.
rows - the rows of the query result.
executionTime - the execution time.
startIndex - the index where to start displaying the results.
hitsPerPage - the number of hits to display on a page (0 for unlimited results on one page).
Method Detail

getTotalMatches

public long getTotalMatches()
Specified by:
getTotalMatches in interface SearchResult
Returns:
the total number of matches.

getStartIndex

public long getStartIndex()
Specified by:
getStartIndex in interface SearchResult
Returns:
the start index. i.e. from where to start to display the hits.

getHitsPerPage

public long getHitsPerPage()
Specified by:
getHitsPerPage in interface SearchResult
Returns:
the number of hits to display on a page.

getHits

public List<Hit> getHits()
Specified by:
getHits in interface SearchResult
Returns:
a List of Hits to display on the result page.

getResultPages

public List<ResultPage> getResultPages()
Specified by:
getResultPages in interface SearchResult
Returns:
a List of ResultPagees to display the navigation through the result pages.

getPreviousPage

public ResultPage getPreviousPage()
Specified by:
getPreviousPage in interface SearchResult
Returns:
the page, which contains the information about the previous page. Returns null if there is no previous page (i.e. the current page is the first page).

getNextPage

public ResultPage getNextPage()
Specified by:
getNextPage in interface SearchResult
Returns:
the page, which contains the information about the next page. Returns null if there is no next page (i.e. the current page is the last page).

getExecutionTime

public String getExecutionTime()
Returns the execution time in fractions of a second.
Example: 0.08 (means, the query took 80 milliseconds to execute).

Specified by:
getExecutionTime in interface SearchResult
Returns:
the execution time of the query.

getExecutionTimeMillis

public long getExecutionTimeMillis()
Returns the execution time in milliseconds.

Specified by:
getExecutionTimeMillis in interface SearchResult
Returns:
the execution time of the query.

getFacets

public Map<String,Facet> getFacets()
                            throws RepositoryException
Returns the facets for this search result.

Specified by:
getFacets in interface SearchResult
Returns:
the facets for this search result.
Throws:
RepositoryException - if an error occurs while executing the query or calculating the facets.

getQueryStatement

public String getQueryStatement()
Description copied from interface: SearchResult
Returns the actual query string run against the repository, eg. an XPath statement. Please note that this does not describe the full query - for a simple list of the predicates that filter see SearchResult.getFilteringPredicates().

Specified by:
getQueryStatement in interface SearchResult
Returns:
a string of the query that was created

getFilteringPredicates

public String getFilteringPredicates()
Description copied from interface: SearchResult
Returns a string with a list of the predicates that were filtering the result set (as opposed to using XPath, see SearchResult.getQueryStatement()). The returned string is for informational purposes only and might not fully describe the predicates and their parameters.

Specified by:
getFilteringPredicates in interface SearchResult
Returns:
a string mentioning all the predicates that filtered the result set


Copyright © 2009 Day Management AG. All Rights Reserved.