net.sourceforge.openutils.mgnlcriteria.jcr.query.xpath.impl
Class AbstractCriteriaImpl

java.lang.Object
  extended by net.sourceforge.openutils.mgnlcriteria.jcr.query.xpath.impl.AbstractCriteriaImpl
All Implemented Interfaces:
Criteria, ExecutableQuery, TranslatableCriteria
Direct Known Subclasses:
AdvancedCriteriaImpl

public abstract class AbstractCriteriaImpl
extends Object
implements TranslatableCriteria

A generic Criteria implementation.

Version:
$Id: AbstractCriteriaImpl.java 3369 2011-03-05 20:08:02Z fgiust $
Author:
fgrilli

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.sourceforge.openutils.mgnlcriteria.jcr.query.TranslatableCriteria
TranslatableCriteria.CriterionEntry, TranslatableCriteria.OrderEntry
 
Field Summary
protected  Class<?> classType
           
protected  List<TranslatableCriteria.CriterionEntry> criterionEntries
           
protected  boolean forcePagingWithDocumentOrder
           
protected  org.slf4j.Logger log
           
protected  int maxResults
           
protected  int offset
           
protected  List<TranslatableCriteria.OrderEntry> orderEntries
           
protected  String path
           
protected  String spellCheckString
           
protected  String workspace
           
 
Constructor Summary
protected AbstractCriteriaImpl()
           
 
Method Summary
 Criteria add(Criterion criterion)
          Add a restriction to constrain the results to be retrieved.
 Criteria addOrder(Order order)
          Add an ordering to the result set.
 AdvancedResult execute()
          Executes the query
 Collection<TranslatableCriteria.CriterionEntry> getCriterionEntries()
          Gets the Order entries of this Criteria instance.
 int getFirstResult()
          Returns the firstResult.
 int getMaxResults()
          Returns the maxResults.
 Collection<TranslatableCriteria.OrderEntry> getOrderEntries()
          Gets the Order entries of this Criteria instance.
 Criteria setBasePath(String path)
          Sets the base path of the query, i.e.
 Criteria setFirstResult(int firstResult)
          Set the first result to be retrieved.
 Criteria setForcePagingWithDocumentOrder(boolean force)
           Enable paging while keeping results sorted in document order.
 Criteria setMaxResults(int maxResults)
          Set a limit upon the number of objects to be retrieved.
 Criteria setPaging(int itemsPerPage, int pageNumberStartingFromOne)
          
 Criteria setSpellCheckString(String spellCheckString)
          Sets the original input string for spell checking.
 Criteria setWorkspace(String workspace)
          Sets the name of the workspace where the search will take place
 String toXpathExpression()
          Returns the generated xpath expression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected org.slf4j.Logger log

path

protected String path

classType

protected Class<?> classType

criterionEntries

protected List<TranslatableCriteria.CriterionEntry> criterionEntries

orderEntries

protected List<TranslatableCriteria.OrderEntry> orderEntries

maxResults

protected int maxResults

offset

protected int offset

spellCheckString

protected String spellCheckString

workspace

protected String workspace

forcePagingWithDocumentOrder

protected boolean forcePagingWithDocumentOrder
Constructor Detail

AbstractCriteriaImpl

protected AbstractCriteriaImpl()
Method Detail

getCriterionEntries

public Collection<TranslatableCriteria.CriterionEntry> getCriterionEntries()
Gets the Order entries of this Criteria instance.

Specified by:
getCriterionEntries in interface TranslatableCriteria
Returns:
a collection of Criterion entries

getOrderEntries

public Collection<TranslatableCriteria.OrderEntry> getOrderEntries()
Gets the Order entries of this Criteria instance.

Specified by:
getOrderEntries in interface TranslatableCriteria
Returns:
a collection of Order entries

add

public Criteria add(Criterion criterion)
Add a restriction to constrain the results to be retrieved.

Specified by:
add in interface Criteria
Parameters:
criterion - The criterion object representing the restriction to be applied.
Returns:
this (for method chaining)

addOrder

public Criteria addOrder(Order order)
Add an ordering to the result set. Only one Order criterion per query can be applied. Any Order added after the first one will be ignored.

Specified by:
addOrder in interface Criteria
Parameters:
order - The order object representing an ordering to be applied to the results.
Returns:
this (for method chaining)

setBasePath

public Criteria setBasePath(String path)
Sets the base path of the query, i.e. the branch in the repository tree where the search will take place

Specified by:
setBasePath in interface Criteria
Parameters:
path - the handle of a node, or a xpath query prefix in the form //handle/of/a/node//*
Returns:
this (for method chaining)

getFirstResult

public int getFirstResult()
Returns the firstResult.

Returns:
the firstResult

setFirstResult

public Criteria setFirstResult(int firstResult)
Set the first result to be retrieved.

Specified by:
setFirstResult in interface Criteria
Parameters:
firstResult - the first result to retrieve, numbered from 0
Returns:
this (for method chaining)

getMaxResults

public int getMaxResults()
Returns the maxResults.

Returns:
the maxResults

setMaxResults

public Criteria setMaxResults(int maxResults)
Set a limit upon the number of objects to be retrieved.

Specified by:
setMaxResults in interface Criteria
Parameters:
maxResults - the maximum number of results
Returns:
this (for method chaining)

setPaging

public Criteria setPaging(int itemsPerPage,
                          int pageNumberStartingFromOne)

Specified by:
setPaging in interface Criteria
Parameters:
itemsPerPage - maximum number of results per page (i.e. page size)
pageNumberStartingFromOne - page number to retrieve (1, 2, 3, ...)
Returns:
this (for method chaining)

setSpellCheckString

public Criteria setSpellCheckString(String spellCheckString)
Sets the original input string for spell checking.

Specified by:
setSpellCheckString in interface Criteria
Parameters:
spellCheckString - the actual input string for spell checking
Returns:
this (for method chaining)

setWorkspace

public Criteria setWorkspace(String workspace)
Sets the name of the workspace where the search will take place

Specified by:
setWorkspace in interface Criteria
Parameters:
workspace - the name of a workspace
Returns:
this (for method chaining)

setForcePagingWithDocumentOrder

public Criteria setForcePagingWithDocumentOrder(boolean force)

Enable paging while keeping results sorted in document order.

Document order is only applied by jackrabbit after the paginated result has been retrieved.

This means that if you have 20 nodes and you want to retrieve them in 2 pages containing 10 elements, only the order of elements in a single page is kept (but the "first" 10 noted in the first page will not be the nodes you are expecting in document order). Setting this flag to true forces the retrieval of the full list of nodes and a post-pagination which will mimic the behaviour you get when an "order by" is specified.

Warning: this has surely a performance hit, since jackrabbit applied document ordering by retrieving any single node (while normally pagination is applied directly on the luce index).

Specified by:
setForcePagingWithDocumentOrder in interface Criteria
Parameters:
force - true to force paging while keeping results sorted in document order
Returns:
this (for method chaining)

toXpathExpression

public String toXpathExpression()
Returns the generated xpath expression

Specified by:
toXpathExpression in interface Criteria
Returns:
the generated xpath expression

execute

public AdvancedResult execute()
Executes the query

Specified by:
execute in interface ExecutableQuery
Returns:
the search result


Copyright © 2009-2011 Openmind. All Rights Reserved.