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 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 the PredicateEvaluator 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 Details

    • AbstractPredicateEvaluator

      public AbstractPredicateEvaluator()
  • Method Details

    • getXPathExpression

      public String getXPathExpression(Predicate predicate, EvaluationContext context)
      Default implementation that always returns null, ie. adds nothing to the XPath query. Subclasses can choose whether they want to implement this method or use the includes(Predicate, Row, EvaluationContext) method for advanced filtering (or both).
      Specified by:
      getXPathExpression in interface PredicateEvaluator
      Parameters:
      predicate - predicate (for this evaluator type) which is evaluated
      context - helper class which provides access to various elements of the query evaluation
      Returns:
      string containing an XPath predicateEvaluator expression
    • getOrderByProperties

      public String[] getOrderByProperties(Predicate predicate, EvaluationContext context)
      Default implementation that always returns null.
      Specified by:
      getOrderByProperties in interface PredicateEvaluator
      Parameters:
      predicate - predicate (for this evaluator type) which is evaluated
      context - 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 deprecated isFiltering(Predicate, EvaluationContext) method (ie. if not overridden, true).
      Specified by:
      canXpath in interface PredicateEvaluator
      Parameters:
      predicate - predicate (for this evaluator type) which is evaluated
      context - 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 deprecated isFiltering(Predicate, EvaluationContext) method (ie. if not overridden, false).
      Specified by:
      canFilter in interface PredicateEvaluator
      Parameters:
      predicate - predicate (for this evaluator type) which is evaluated
      context - 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 returns false, because the includes(Predicate, Row, EvaluationContext) also always returns true in this implementation and hence does no filtering at all.
      Specified by:
      isFiltering in interface PredicateEvaluator
      Parameters:
      predicate - predicate (for this evaluator type) which is evaluated
      context - 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 returns true, ie. it does not "touch" the result set at all.
      Specified by:
      includes in interface PredicateEvaluator
      Parameters:
      predicate - predicate (for this evaluator type) which is evaluated
      row - current row of the result set returned through the xpath query
      context - 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 Comparator<Row> getOrderByComparator(Predicate predicate, EvaluationContext context)
      Default implementation that always returns null.
      Specified by:
      getOrderByComparator in interface PredicateEvaluator
      Parameters:
      predicate - predicate (for this evaluator type) which is evaluated
      context - 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 returns null, ie. no facets will be extracted for the predicate.
      Specified by:
      getFacetExtractor in interface PredicateEvaluator
      Parameters:
      predicate - predicate (for this evaluator type) which is evaluated
      context - helper class which provides access to various elements of the query evaluation
      Returns:
      a FacetExtractor that is used to create a Facet or null if no extractor shall be provided