Package com.day.cq.search.eval
Class DateRangePredicateEvaluator
- java.lang.Object
-
- com.day.cq.search.eval.AbstractPredicateEvaluator
-
- com.day.cq.search.eval.RangePropertyPredicateEvaluator
-
- com.day.cq.search.eval.DateRangePredicateEvaluator
-
- All Implemented Interfaces:
PredicateEvaluator
- Direct Known Subclasses:
RelativeDateRangePredicateEvaluator
public class DateRangePredicateEvaluator extends RangePropertyPredicateEvaluator
Matches JCR DATE properties against a date/time interval. This uses the ISO8601 format for dates and times (YYYY-MM-DDTHH:mm:ss.SSSZ
) and allows also partial representations (eg.YYYY-MM-DD
). Alternatively, the timestamp can be provided as number of milliseconds since 1970 (UTC timezone, the unix time format).You can ask for anything between two timestamps, anything newer or older than a given date, and also chose between inclusive and open intervals.
Supports facet extraction. Will provide buckets "today", "this week", "this month", "last 3 months", "this year", "last year" and "earlier than last year".
Does not support filtering.
Name:
daterangeProperties:
- property
- relative path to a DATE property, for example
jcr:lastModified
- lowerBound
- lower date bound to check property for, for example
2014-10-01
- lowerOperation
- ">" (newer, default) or ">=" (at or newer), applies to the lowerBound
- upperBound
- upper bound to check property for, for example
2014-10-01T12:15:00
- upperOperation
- "<" (older, default) or "<=" (at or older), applies to the upperBound
- timeZone
- ID of timezone to use when it's not given as ISO-8601 date string; default is the default timezone of the system
- Since:
- 5.2
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
EARLIER_THAN_LAST_YEAR
static java.lang.String
LAST_THREE_MONTHS
static java.lang.String
LAST_YEAR
static java.lang.String
THIS_MONTH
static java.lang.String
THIS_WEEK
static java.lang.String
THIS_YEAR
static java.lang.String
TIME_ZONE
static java.lang.String
TODAY
-
Fields inherited from class com.day.cq.search.eval.RangePropertyPredicateEvaluator
LOWER_BOUND, LOWER_OPERATION, PROPERTY, PROPERTY_DECIMAL, UPPER_BOUND, UPPER_OPERATION
-
-
Constructor Summary
Constructors Constructor Description DateRangePredicateEvaluator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canFilter(Predicate p, EvaluationContext context)
Returns the same as the deprecatedAbstractPredicateEvaluator.isFiltering(Predicate, EvaluationContext)
method (ie.boolean
canXpath(Predicate p, EvaluationContext context)
Returns the inverted boolean value of the deprecatedAbstractPredicateEvaluator.isFiltering(Predicate, EvaluationContext)
method (ie.FacetExtractor
getFacetExtractor(Predicate p, EvaluationContext context)
Default implementation that always returnsnull
, ie.java.lang.String
getXPathExpression(Predicate p, EvaluationContext context)
Default implementation that always returnsnull
, ie.static java.lang.String
parseDateString(java.lang.String dateString, java.lang.String timeZoneID, Session session)
-
Methods inherited from class com.day.cq.search.eval.RangePropertyPredicateEvaluator
getOrderByProperties, includes
-
Methods inherited from class com.day.cq.search.eval.AbstractPredicateEvaluator
getOrderByComparator, isFiltering
-
-
-
-
Field Detail
-
TIME_ZONE
public static final java.lang.String TIME_ZONE
- See Also:
- Constant Field Values
-
TODAY
public static final java.lang.String TODAY
- See Also:
- Constant Field Values
-
THIS_WEEK
public static final java.lang.String THIS_WEEK
- See Also:
- Constant Field Values
-
THIS_MONTH
public static final java.lang.String THIS_MONTH
- See Also:
- Constant Field Values
-
LAST_THREE_MONTHS
public static final java.lang.String LAST_THREE_MONTHS
- See Also:
- Constant Field Values
-
THIS_YEAR
public static final java.lang.String THIS_YEAR
- See Also:
- Constant Field Values
-
LAST_YEAR
public static final java.lang.String LAST_YEAR
- See Also:
- Constant Field Values
-
EARLIER_THAN_LAST_YEAR
public static final java.lang.String EARLIER_THAN_LAST_YEAR
- See Also:
- Constant Field Values
-
-
Method Detail
-
getXPathExpression
public java.lang.String getXPathExpression(Predicate p, EvaluationContext context)
Description copied from class:AbstractPredicateEvaluator
Default implementation that always returnsnull
, ie. adds nothing to the XPath query. Subclasses can choose whether they want to implement this method or use theAbstractPredicateEvaluator.includes(Predicate, Row, EvaluationContext)
method for advanced filtering (or both).- Specified by:
getXPathExpression
in interfacePredicateEvaluator
- Overrides:
getXPathExpression
in classRangePropertyPredicateEvaluator
- Parameters:
p
- 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
-
canFilter
public boolean canFilter(Predicate p, EvaluationContext context)
Description copied from class:AbstractPredicateEvaluator
Returns the same as the deprecatedAbstractPredicateEvaluator.isFiltering(Predicate, EvaluationContext)
method (ie. if not overridden,false
).- Specified by:
canFilter
in interfacePredicateEvaluator
- Overrides:
canFilter
in classRangePropertyPredicateEvaluator
- Parameters:
p
- 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)
-
canXpath
public boolean canXpath(Predicate p, EvaluationContext context)
Description copied from class:AbstractPredicateEvaluator
Returns the inverted boolean value of the deprecatedAbstractPredicateEvaluator.isFiltering(Predicate, EvaluationContext)
method (ie. if not overridden,true
).- Specified by:
canXpath
in interfacePredicateEvaluator
- Overrides:
canXpath
in classRangePropertyPredicateEvaluator
- Parameters:
p
- 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)
-
parseDateString
public static java.lang.String parseDateString(java.lang.String dateString, java.lang.String timeZoneID, Session session)
-
getFacetExtractor
public FacetExtractor getFacetExtractor(Predicate p, EvaluationContext context)
Description copied from class:AbstractPredicateEvaluator
Default implementation that always returnsnull
, ie. no facets will be extracted for the predicate.- Specified by:
getFacetExtractor
in interfacePredicateEvaluator
- Overrides:
getFacetExtractor
in classAbstractPredicateEvaluator
- Parameters:
p
- 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
-
-