Class QueryResultImpl
- java.lang.Object
-
- org.apache.jackrabbit.core.query.lucene.QueryResultImpl
-
- All Implemented Interfaces:
QueryResult
,JackrabbitQueryResult
- Direct Known Subclasses:
MultiColumnQueryResult
,SingleColumnQueryResult
public abstract class QueryResultImpl extends Object implements JackrabbitQueryResult
Implements theQueryResult
interface.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,ColumnImpl>
columns
The columns to select.protected boolean
docOrder
Iftrue
nodes are returned in document order.protected SearchIndex
index
The search index to execute the query.protected AbstractQueryImpl
queryImpl
The query instance which created this query result.protected SessionContext
sessionContext
Component context of the current sessionprotected org.apache.jackrabbit.core.query.lucene.SpellSuggestion
spellSuggestion
The spell suggestion ornull
if not available.
-
Constructor Summary
Constructors Constructor Description QueryResultImpl(SearchIndex index, SessionContext sessionContext, AbstractQueryImpl queryImpl, org.apache.jackrabbit.core.query.lucene.SpellSuggestion spellSuggestion, ColumnImpl[] columns, boolean documentOrder, long offset, long limit)
Creates a new query result.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ExcerptProvider
createExcerptProvider()
Creates an excerpt provider for this result set.protected abstract MultiColumnQueryHits
executeQuery(long resultFetchHint)
Executes the query for this result and returns hits.String[]
getColumnNames()
NodeIterator
getNodes()
protected void
getResults(long size)
Attempts to getsize
results and puts them intoresultNodes
.RowIterator
getRows()
String[]
getSelectorNames()
int
getTotalSize()
Returns the total number of hits.protected boolean
isAccessGranted(ScoreNode[] nodes)
Checks if access is granted to allnodes
.
-
-
-
Field Detail
-
index
protected final SearchIndex index
The search index to execute the query.
-
sessionContext
protected final SessionContext sessionContext
Component context of the current session
-
queryImpl
protected final AbstractQueryImpl queryImpl
The query instance which created this query result.
-
spellSuggestion
protected final org.apache.jackrabbit.core.query.lucene.SpellSuggestion spellSuggestion
The spell suggestion ornull
if not available.
-
columns
protected final Map<String,ColumnImpl> columns
The columns to select.
-
docOrder
protected final boolean docOrder
Iftrue
nodes are returned in document order.
-
-
Constructor Detail
-
QueryResultImpl
public QueryResultImpl(SearchIndex index, SessionContext sessionContext, AbstractQueryImpl queryImpl, org.apache.jackrabbit.core.query.lucene.SpellSuggestion spellSuggestion, ColumnImpl[] columns, boolean documentOrder, long offset, long limit) throws RepositoryException
Creates a new query result. The concrete sub class is responsible for callinggetResults(long)
after this constructor had been called.- Parameters:
index
- the search index where the query is executed.sessionContext
- component context of the current sessionqueryImpl
- the query instance which created this query result.spellSuggestion
- the spell suggestion ornull
if none is available.columns
- the select properties of the query.documentOrder
- iftrue
the result is returned in document order.limit
- the maximum result sizeoffset
- the offset in the total result set- Throws:
RepositoryException
- if an error occurs while reading from the repository.IllegalArgumentException
- if any of the columns does not have a column name.
-
-
Method Detail
-
getSelectorNames
public String[] getSelectorNames() throws RepositoryException
- Specified by:
getSelectorNames
in interfaceQueryResult
- Throws:
RepositoryException
-
getColumnNames
public String[] getColumnNames() throws RepositoryException
- Specified by:
getColumnNames
in interfaceQueryResult
- Throws:
RepositoryException
-
getNodes
public NodeIterator getNodes() throws RepositoryException
- Specified by:
getNodes
in interfaceQueryResult
- Throws:
RepositoryException
-
getRows
public RowIterator getRows() throws RepositoryException
- Specified by:
getRows
in interfaceQueryResult
- Throws:
RepositoryException
-
executeQuery
protected abstract MultiColumnQueryHits executeQuery(long resultFetchHint) throws IOException
Executes the query for this result and returns hits. The caller must close the query hits when he is done using it.- Parameters:
resultFetchHint
- a hint on how many results should be fetched.- Returns:
- hits for this query result.
- Throws:
IOException
- if an error occurs while executing the query.
-
createExcerptProvider
protected abstract ExcerptProvider createExcerptProvider() throws IOException
Creates an excerpt provider for this result set.- Returns:
- an excerpt provider.
- Throws:
IOException
- if an error occurs.
-
getResults
protected void getResults(long size) throws RepositoryException
Attempts to getsize
results and puts them intoresultNodes
. If the size ofresultNodes
is less thansize
then there are no more thanresultNodes.size()
results for this query.- Parameters:
size
- the number of results to fetch for the query.- Throws:
RepositoryException
- if an error occurs while executing the query.
-
isAccessGranted
protected boolean isAccessGranted(ScoreNode[] nodes) throws RepositoryException
Checks if access is granted to allnodes
.- Parameters:
nodes
- the nodes to check.- Returns:
true
if read access is granted to allnodes
.- Throws:
RepositoryException
- if an error occurs while checking access rights.
-
getTotalSize
public int getTotalSize()
Returns the total number of hits. This is the number of results you will get get if you don't set any limit or offset. This method may return-1
if the total size is unknown.If the "sizeEstimate" options is enabled: Keep in mind that this number may get smaller if nodes are found in the result set which the current session has no permission to access. This might be a security problem.
- Specified by:
getTotalSize
in interfaceJackrabbitQueryResult
- Returns:
- the total number of hits.
-
-