org.alfresco.repo.webservice
Class AbstractQuerySession

java.lang.Object
  extended by org.alfresco.repo.webservice.AbstractQuerySession
All Implemented Interfaces:
java.io.Serializable, QuerySession
Direct Known Subclasses:
RepositoryQuerySession, UserQuerySession

public abstract class AbstractQuerySession
extends java.lang.Object
implements QuerySession

An abstract implementation of the query session that keeps track of the paging data. It provides support for paging of results of Serializable[] instances.

Since:
2.1
See Also:
Serialized Form

Constructor Summary
AbstractQuerySession(long maxResults, long batchSize, ServerQuery query)
          Common constructor that initialises the session's id and batch size
 
Method Summary
 java.lang.String getId()
          Retrieves the id this query session can be identified as
protected  java.lang.Object[] getNextResults(java.lang.Object[] allResults)
          Helper method to page through the results.
 ServerQuery getQuery()
          
protected  java.lang.Object getQueryResults(org.alfresco.service.ServiceRegistry serviceRegistry)
          Helper method to get the results.
 boolean haveMoreResults()
          Check if the session is expecting more results.
protected abstract  java.lang.Object[] makeArray(int size)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.alfresco.repo.webservice.QuerySession
getNextResults
 

Constructor Detail

AbstractQuerySession

public AbstractQuerySession(long maxResults,
                            long batchSize,
                            ServerQuery query)
Common constructor that initialises the session's id and batch size

Parameters:
maxResults - the maximum number of results to retrieve for the query. This is not the page size, which is normally significantly smaller.
batchSize - the batch size this session will use
query - the query that generates the results
Method Detail

getId

public java.lang.String getId()
Retrieves the id this query session can be identified as

Specified by:
getId in interface QuerySession
Returns:
Id of this query session

getQuery

public ServerQuery getQuery()


getQueryResults

protected java.lang.Object getQueryResults(org.alfresco.service.ServiceRegistry serviceRegistry)
Helper method to get the results. This may be a cached value or may be freshly retrieved from the query object.

Parameters:
serviceRegistry - the
Returns:
the query results, new or cached

haveMoreResults

public boolean haveMoreResults()
Check if the session is expecting more results. This will be false if the cursor previously passed the end of a given set of results.

Specified by:
haveMoreResults in interface QuerySession

makeArray

protected abstract java.lang.Object[] makeArray(int size)

getNextResults

protected final java.lang.Object[] getNextResults(java.lang.Object[] allResults)
Helper method to page through the results. The task of retrieving, unwrapping and rewrapping the array of results (rows) is left up to the derived implementations.



Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.