Package com.day.cq.search.eval
Class AbstractPredicateEvaluator
- java.lang.Object
-
- com.day.cq.search.eval.AbstractPredicateEvaluator
-
- All Implemented Interfaces:
PredicateEvaluator
- Direct Known Subclasses:
AssetRenditionFilterPredicateEvaluator
,CollectionPredicateEvaluator
,FulltextPredicateEvaluator
,JcrPropertyPredicateEvaluator
,NodenamePredicateEvaluator
,PathPredicateEvaluator
,PermissionPredicateEvaluator
,PredicateGroupEvaluator
,RangePropertyPredicateEvaluator
,SimilarityPredicateEvaluator
,SubAssetFilterPredicateEvaluator
,TypePredicateEvaluator
public abstract class AbstractPredicateEvaluator extends java.lang.Object implements PredicateEvaluator
AbstractPredicateEvaluator
is a base implementation for predicate evaluators. Predicate evaluator implementations are encouraged to extend from this abstract base class to minimize migration efforts when new changes are added to thePredicateEvaluator
API.This implementation basically does "nothing":
- returns no xpath expression
- does not filter
- (implementations have to implement at least one of the two above)
- provides no order by properties or order comparator
- provides no facet extractor
- automatically covers newer interface methods by implementing them using the old methods
- Since:
- 5.2
-
-
Constructor Summary
Constructors Constructor Description AbstractPredicateEvaluator()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
canFilter(Predicate predicate, EvaluationContext context)
Returns the same as the deprecatedisFiltering(Predicate, EvaluationContext)
method (ie.boolean
canXpath(Predicate predicate, EvaluationContext context)
Returns the inverted boolean value of the deprecatedisFiltering(Predicate, EvaluationContext)
method (ie.FacetExtractor
getFacetExtractor(Predicate predicate, EvaluationContext context)
Default implementation that always returnsnull
, ie.java.util.Comparator<Row>
getOrderByComparator(Predicate predicate, EvaluationContext context)
Default implementation that always returnsnull
.java.lang.String[]
getOrderByProperties(Predicate predicate, EvaluationContext context)
Default implementation that always returnsnull
.java.lang.String
getXPathExpression(Predicate predicate, EvaluationContext context)
Default implementation that always returnsnull
, ie.boolean
includes(Predicate predicate, Row row, EvaluationContext context)
Default implementation that always returnstrue
, ie.boolean
isFiltering(Predicate predicate, EvaluationContext context)
Deprecated.
-
-
-
Method Detail
-
getXPathExpression
public java.lang.String getXPathExpression(Predicate predicate, EvaluationContext context)
Default implementation that always returnsnull
, ie. adds nothing to the XPath query. Subclasses can choose whether they want to implement this method or use theincludes(Predicate, Row, EvaluationContext)
method for advanced filtering (or both).- Specified by:
getXPathExpression
in interfacePredicateEvaluator
- Parameters:
predicate
- predicate (for this evaluator type) which is evaluatedcontext
- helper class which provides access to various elements of the query evaluation- Returns:
- string containing an XPath predicateEvaluator expression
-
getOrderByProperties
public java.lang.String[] getOrderByProperties(Predicate predicate, EvaluationContext context)
Default implementation that always returnsnull
.- Specified by:
getOrderByProperties
in interfacePredicateEvaluator
- Parameters:
predicate
- predicate (for this evaluator type) which is evaluatedcontext
- helper class which provides access to various elements of the query evaluation- Returns:
- one or multiple relative paths to JCR properties or
null
-
canXpath
public boolean canXpath(Predicate predicate, EvaluationContext context)
Returns the inverted boolean value of the deprecatedisFiltering(Predicate, EvaluationContext)
method (ie. if not overridden,true
).- Specified by:
canXpath
in interfacePredicateEvaluator
- Parameters:
predicate
- predicate (for this evaluator type) which is evaluatedcontext
- helper class which provides access to various elements of the query evaluation- Returns:
true
if this evaluator can express itself via xpath, ie.PredicateEvaluator.getXPathExpression(Predicate, EvaluationContext)
-
canFilter
public boolean canFilter(Predicate predicate, EvaluationContext context)
Returns the same as the deprecatedisFiltering(Predicate, EvaluationContext)
method (ie. if not overridden,false
).- Specified by:
canFilter
in interfacePredicateEvaluator
- Parameters:
predicate
- predicate (for this evaluator type) which is evaluatedcontext
- helper class which provides access to various elements of the query evaluation- Returns:
true
if this evaluator can be express itself via filtering, ie.PredicateEvaluator.includes(Predicate, Row, EvaluationContext)
-
isFiltering
@Deprecated public boolean isFiltering(Predicate predicate, EvaluationContext context)
Deprecated.Default implementation that always returnsfalse
, because theincludes(Predicate, Row, EvaluationContext)
also always returnstrue
in this implementation and hence does no filtering at all.- Specified by:
isFiltering
in interfacePredicateEvaluator
- Parameters:
predicate
- predicate (for this evaluator type) which is evaluatedcontext
- helper class which provides access to various elements of the query evaluation- Returns:
true
if this evaluator is filtering the result set for the given predicate
-
includes
public boolean includes(Predicate predicate, Row row, EvaluationContext context)
Default implementation that always returnstrue
, ie. it does not "touch" the result set at all.- Specified by:
includes
in interfacePredicateEvaluator
- Parameters:
predicate
- predicate (for this evaluator type) which is evaluatedrow
- current row of the result set returned through the xpath querycontext
- helper class which provides access to various elements of the query evaluation- Returns:
true
if this row should be part of the final result set,false
if it should be dropped
-
getOrderByComparator
public java.util.Comparator<Row> getOrderByComparator(Predicate predicate, EvaluationContext context)
Default implementation that always returnsnull
.- Specified by:
getOrderByComparator
in interfacePredicateEvaluator
- Parameters:
predicate
- predicate (for this evaluator type) which is evaluatedcontext
- helper class which provides access to various elements of the query evaluation- Returns:
- a custom comparator for the given predicate or
null
-
getFacetExtractor
public FacetExtractor getFacetExtractor(Predicate predicate, EvaluationContext context)
Default implementation that always returnsnull
, ie. no facets will be extracted for the predicate.- Specified by:
getFacetExtractor
in interfacePredicateEvaluator
- Parameters:
predicate
- predicate (for this evaluator type) which is evaluatedcontext
- helper class which provides access to various elements of the query evaluation- Returns:
- a
FacetExtractor
that is used to create aFacet
ornull
if no extractor shall be provided
-
-