com.day.cq.search.eval
Class RangePropertyPredicateEvaluator

java.lang.Object
  extended by com.day.cq.search.eval.AbstractPredicateEvaluator
      extended by com.day.cq.search.eval.RangePropertyPredicateEvaluator
All Implemented Interfaces:
PredicateEvaluator
Direct Known Subclasses:
DateRangePredicateEvaluator

public class RangePropertyPredicateEvaluator
extends AbstractPredicateEvaluator

RangePropertyPredicateEvaluator is a generic evaluator for checking a jcr property against an interval. This applies to properties with linear types such as LONG, DOUBLE and DATE (for date there is a specific DateRangePredicateEvaluator that can handle the specific format).

You can define a lower bound and an upper bound or only one of them. The operation (eg. "lesser than" or "lesser or equals") can also be specified for lower and upper bound individually.

Name:

rangeproperty

Properties:

property
relative path to property
lowerBound
lower bound to check property for
lowerOperation
">" (default) or ">=", applies to the lowerValue
upperBound
upper bound to check property for
upperOperation
"<" (default) or "<=", applies to the lowerValue
decimal
(boolean) if the checked property is of type Decimal

Since:
5.2

Field Summary
static String LOWER_BOUND
           
static String LOWER_OPERATION
           
static String PROPERTY
           
static String PROPERTY_DECIMAL
           
static String UPPER_BOUND
           
static String UPPER_OPERATION
           
 
Constructor Summary
RangePropertyPredicateEvaluator()
           
 
Method Summary
 boolean canFilter(Predicate p, EvaluationContext context)
          Returns the same as the deprecated AbstractPredicateEvaluator.isFiltering(Predicate, EvaluationContext) method (ie. if not overridden, false).
 boolean canXpath(Predicate p, EvaluationContext context)
          Returns the inverted boolean value of the deprecated AbstractPredicateEvaluator.isFiltering(Predicate, EvaluationContext) method (ie. if not overridden, true).
 String[] getOrderByProperties(Predicate p, EvaluationContext context)
          Default implementation that always returns null.
 String getXPathExpression(Predicate p, EvaluationContext context)
          Default implementation that always returns null, ie. adds nothing to the XPath query.
protected  String getXPathExpression(String property, String lowerValue, String lowerOperation, String upperValue, String upperOperation)
           
protected  boolean includes(Node node, String property, String lowerValue, String lowerOperation, String upperValue, String upperOperation, boolean decimal)
           
 boolean includes(Predicate p, Row row, EvaluationContext context)
          Default implementation that always returns true, ie. it does not "touch" the result set at all.
 
Methods inherited from class com.day.cq.search.eval.AbstractPredicateEvaluator
getFacetExtractor, getOrderByComparator, isFiltering
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY

public static final String PROPERTY
See Also:
Constant Field Values

LOWER_BOUND

public static final String LOWER_BOUND
See Also:
Constant Field Values

LOWER_OPERATION

public static final String LOWER_OPERATION
See Also:
Constant Field Values

UPPER_BOUND

public static final String UPPER_BOUND
See Also:
Constant Field Values

UPPER_OPERATION

public static final String UPPER_OPERATION
See Also:
Constant Field Values

PROPERTY_DECIMAL

public static final String PROPERTY_DECIMAL
See Also:
Constant Field Values
Constructor Detail

RangePropertyPredicateEvaluator

public RangePropertyPredicateEvaluator()
Method Detail

getXPathExpression

public String getXPathExpression(Predicate p,
                                 EvaluationContext context)
Description copied from class: AbstractPredicateEvaluator
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 AbstractPredicateEvaluator.includes(Predicate, Row, EvaluationContext) method for advanced filtering (or both).

Specified by:
getXPathExpression in interface PredicateEvaluator
Overrides:
getXPathExpression in class AbstractPredicateEvaluator
Parameters:
p - 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

getXPathExpression

protected String getXPathExpression(String property,
                                    String lowerValue,
                                    String lowerOperation,
                                    String upperValue,
                                    String upperOperation)

getOrderByProperties

public String[] getOrderByProperties(Predicate p,
                                     EvaluationContext context)
Description copied from class: AbstractPredicateEvaluator
Default implementation that always returns null.

Specified by:
getOrderByProperties in interface PredicateEvaluator
Overrides:
getOrderByProperties in class AbstractPredicateEvaluator
Parameters:
p - 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 p,
                        EvaluationContext context)
Description copied from class: AbstractPredicateEvaluator
Returns the inverted boolean value of the deprecated AbstractPredicateEvaluator.isFiltering(Predicate, EvaluationContext) method (ie. if not overridden, true).

Specified by:
canXpath in interface PredicateEvaluator
Overrides:
canXpath in class AbstractPredicateEvaluator
Parameters:
p - 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 p,
                         EvaluationContext context)
Description copied from class: AbstractPredicateEvaluator
Returns the same as the deprecated AbstractPredicateEvaluator.isFiltering(Predicate, EvaluationContext) method (ie. if not overridden, false).

Specified by:
canFilter in interface PredicateEvaluator
Overrides:
canFilter in class AbstractPredicateEvaluator
Parameters:
p - 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)

includes

public boolean includes(Predicate p,
                        Row row,
                        EvaluationContext context)
Description copied from class: AbstractPredicateEvaluator
Default implementation that always returns true, ie. it does not "touch" the result set at all.

Specified by:
includes in interface PredicateEvaluator
Overrides:
includes in class AbstractPredicateEvaluator
Parameters:
p - 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

includes

protected boolean includes(Node node,
                           String property,
                           String lowerValue,
                           String lowerOperation,
                           String upperValue,
                           String upperOperation,
                           boolean decimal)


Copyright © 2011-2013 Adobe Systems Incorporated. All Rights Reserved.