org.hippoecm.hst.content.beans.query
Class HstQueryImpl

java.lang.Object
  extended by org.hippoecm.hst.content.beans.query.HstQueryImpl
All Implemented Interfaces:
HstQuery

public class HstQueryImpl
extends Object
implements HstQuery


Field Summary
 
Fields inherited from interface org.hippoecm.hst.content.beans.query.HstQuery
DEFAULT_LIMIT
 
Constructor Summary
HstQueryImpl(javax.jcr.Session session, HstCtxWhereClauseComputer hstCtxWhereClauseComputer, ObjectConverter objectConverter, javax.jcr.Node scope, IsNodeTypeFilter isNodeTypeFilter)
           
HstQueryImpl(javax.jcr.Session session, HstCtxWhereClauseComputer hstCtxWhereClauseComputer, ObjectConverter objectConverter, javax.jcr.Node scope, NodeTypeFilter nodeTypeFilter)
           
 
Method Summary
 void addOrderByAscending(String fieldNameAttribute)
          Order the object found (ascending)
 void addOrderByDescending(String fieldNameAttribute)
          Order the object found (descending)
 void addScopes(List<HippoBean> scopes)
          add scopes to search in.
 void addScopes(javax.jcr.Node[] scopes)
          add scopes to search in.
 Filter createFilter()
           
 void excludeScopes(List<HippoBean> scopes)
          add scopes to exclude from search.
 void excludeScopes(javax.jcr.Node[] scopes)
          add scopes to exclude from search.
 HstQueryResult execute()
          The actual execution of the HstQuery.
 BaseFilter getFilter()
           
 int getLimit()
          Returns the limit of the HstQuery.
 int getOffset()
          Returns the offset of the HstQuery.
 String getQuery()
           
 String getQueryAsString(boolean skipDefaultOrderBy)
          Returns the query as string.
 void setFilter(BaseFilter filter)
           
 void setLimit(int limit)
          Sets the limit of search results.
 void setOffset(int offset)
          Sets the offset to start searching from.
 void setSkipInvalidScopes(boolean skipInvalidScopes)
          Whether invalid scopes should be skipped, or if an invalid scope is found (jcr node is null, HippoBean is empty, etc), throw a QueryException.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HstQueryImpl

public HstQueryImpl(javax.jcr.Session session,
                    HstCtxWhereClauseComputer hstCtxWhereClauseComputer,
                    ObjectConverter objectConverter,
                    javax.jcr.Node scope,
                    NodeTypeFilter nodeTypeFilter)
Parameters:
session - the jcr session. This session can be null as long as HSTTWO-1600 is not done
hstCtxWhereClauseComputer -
objectConverter -
scope - the scope to search below. Scope can be null
nodeTypeFilter -

HstQueryImpl

public HstQueryImpl(javax.jcr.Session session,
                    HstCtxWhereClauseComputer hstCtxWhereClauseComputer,
                    ObjectConverter objectConverter,
                    javax.jcr.Node scope,
                    IsNodeTypeFilter isNodeTypeFilter)
Parameters:
session - the jcr session. This session can be null as long as HSTTWO-1600 is not done
hstCtxWhereClauseComputer -
objectConverter -
scope - the scope to search below. Scope can be null
isNodeTypeFilter -
Method Detail

addOrderByAscending

public void addOrderByAscending(String fieldNameAttribute)
Description copied from interface: HstQuery
Order the object found (ascending)

Specified by:
addOrderByAscending in interface HstQuery
Parameters:
fieldNameAttribute - the name of the field used to sort the search result

addOrderByDescending

public void addOrderByDescending(String fieldNameAttribute)
Description copied from interface: HstQuery
Order the object found (descending)

Specified by:
addOrderByDescending in interface HstQuery
Parameters:
fieldNameAttribute - the name of the field used to sort the search result

createFilter

public Filter createFilter()
Specified by:
createFilter in interface HstQuery
Returns:
a new empty Filter

getFilter

public BaseFilter getFilter()
Specified by:
getFilter in interface HstQuery

setFilter

public void setFilter(BaseFilter filter)
Specified by:
setFilter in interface HstQuery

setLimit

public void setLimit(int limit)
Description copied from interface: HstQuery
Sets the limit of search results. Note that setting this value very high might influence performance negatively

Specified by:
setLimit in interface HstQuery

getLimit

public int getLimit()
Description copied from interface: HstQuery
Returns the limit of the HstQuery. If no limit is set, it returns the default HstQuery limit HstQuery.DEFAULT_LIMIT

Specified by:
getLimit in interface HstQuery
Returns:
the limit

setOffset

public void setOffset(int offset)
Description copied from interface: HstQuery
Sets the offset to start searching from. Default offset is -1 which means it is ignored. A negative offset will be ignored

Specified by:
setOffset in interface HstQuery

getOffset

public int getOffset()
Description copied from interface: HstQuery
Returns the offset of the HstQuery. If no offset is set through HstQuery.setOffset(int), the offset will be -1 and will be ignored

Specified by:
getOffset in interface HstQuery
Returns:
the offset

getQueryAsString

public String getQueryAsString(boolean skipDefaultOrderBy)
                        throws QueryException
Description copied from interface: HstQuery
Returns the query as string. When skipDefaultOrder is TRUE, the string representation will only include an 'order by' clause when there is set one explicitly.

Specified by:
getQueryAsString in interface HstQuery
Returns:
the query as string
Throws:
QueryException - if we cannot build the query string

getQuery

public String getQuery()
                throws QueryException
Throws:
QueryException

toString

public String toString()
Overrides:
toString in class Object

execute

public HstQueryResult execute()
                       throws QueryException
Description copied from interface: HstQuery
The actual execution of the HstQuery. The HstQueryResult will never contain one and the same result twice. So, if a result matches the search criteria twice, it is still returned as one hit.

Specified by:
execute in interface HstQuery
Returns:
HstQueryResult
Throws:
QueryException

addScopes

public void addScopes(List<HippoBean> scopes)
Description copied from interface: HstQuery
add scopes to search in. If the exact scope is already added to exclude from the search, it is removed from the excluded list.

Specified by:
addScopes in interface HstQuery

addScopes

public void addScopes(javax.jcr.Node[] scopes)
Description copied from interface: HstQuery
add scopes to search in. If the exact scope is already added to exclude from the search, it is removed from the excluded list.

Specified by:
addScopes in interface HstQuery

setSkipInvalidScopes

public void setSkipInvalidScopes(boolean skipInvalidScopes)
Description copied from interface: HstQuery
Whether invalid scopes should be skipped, or if an invalid scope is found (jcr node is null, HippoBean is empty, etc), throw a QueryException. Default HstQuery implementation throw a QueryException when an invalid scope is encountered. If skipInvalid is set to true, then still, when all scopes happen to be invalid, a QueryException is thrown

Specified by:
setSkipInvalidScopes in interface HstQuery
Parameters:
skipInvalidScopes - is true, invalid scopes are ignored

excludeScopes

public void excludeScopes(List<HippoBean> scopes)
Description copied from interface: HstQuery
add scopes to exclude from search. If the exact scope is already added as a scope to search in, it is removed from there

Specified by:
excludeScopes in interface HstQuery

excludeScopes

public void excludeScopes(javax.jcr.Node[] scopes)
Description copied from interface: HstQuery
add scopes to exclude from search. If the exact scope is already added as a scope to search in, it is removed from there

Specified by:
excludeScopes in interface HstQuery


Copyright © 2008-2012 Hippo. All Rights Reserved.