public abstract class ConstraintBuilder extends Object
Modifier | Constructor and Description |
---|---|
protected |
ConstraintBuilder() |
Modifier and Type | Method and Description |
---|---|
static Constraint |
and(Constraint... constraints) |
abstract Constraint |
between(Calendar start,
Calendar end,
DateTools.Resolution dateResolution)
Adds a FAST DATE RANGE constraint that the Calendar value for
fieldAttributeName is between start and end (boundaries included) BASED ON the
granularity resolution . |
abstract Constraint |
between(Object value1,
Object value2)
Adds a constraint that the value
fieldAttributeName is between value1 and value2 (boundaries included). |
static FieldConstraintBuilder |
constraint(String fieldName)
The
fieldName is in general a property name, for example example:title. |
abstract Constraint |
contains(String fullTextSearch)
Adds a fulltext search to this Filter.
|
abstract Constraint |
equalTo(Calendar value,
DateTools.Resolution dateResolution)
Adds a constraint that the Calendar value for
fieldAttributeName rounded to its resolution is equal to the
rounded value for calendar . |
abstract Constraint |
equalTo(Object value)
Adds a constraint that the value
fieldAttributeName is equal to value |
abstract Constraint |
equalToCaseInsensitive(String value)
Case insensitive testing of
fieldAttributeName for some value . |
abstract Constraint |
exists()
Add a constraint that the result does have the property
fieldAttributeName , regardless its value |
abstract Constraint |
greaterOrEqualThan(Calendar value,
DateTools.Resolution dateResolution)
note: supported resolutions are
DateTools.Resolution.YEAR ,
DateTools.Resolution.MONTH ,
DateTools.Resolution.DAY or
DateTools.Resolution.HOUR |
abstract Constraint |
greaterOrEqualThan(Object value)
Adds a constraint that the value
fieldAttributeName is greater than or equal to value |
abstract Constraint |
greaterThan(Calendar value,
DateTools.Resolution dateResolution)
note: supported resolutions are
DateTools.Resolution.YEAR ,
DateTools.Resolution.MONTH ,
DateTools.Resolution.DAY or
DateTools.Resolution.HOUR |
abstract Constraint |
greaterThan(Object value)
Adds a constraint that the value
fieldAttributeName is greater than value |
abstract Constraint |
jcrExpression(String jcrExpression)
Adds the xpath
jcrExpression as constraint. |
abstract Constraint |
lessOrEqualThan(Calendar value,
DateTools.Resolution dateResolution)
note: supported resolutions are
DateTools.Resolution.YEAR ,
DateTools.Resolution.MONTH ,
DateTools.Resolution.DAY or
DateTools.Resolution.HOUR |
abstract Constraint |
lessOrEqualThan(Object value)
Adds a constraint that the value
fieldAttributeName is less than or equal to value |
abstract Constraint |
lessThan(Calendar value,
DateTools.Resolution dateResolution)
note: supported resolutions are
DateTools.Resolution.YEAR ,
DateTools.Resolution.MONTH ,
DateTools.Resolution.DAY or
DateTools.Resolution.HOUR |
abstract Constraint |
lessThan(Object value)
Adds a constraint that the value
fieldAttributeName is less than value |
abstract Constraint |
like(String value)
This function is based on the LIKE predicate found in SQL.
|
abstract Constraint |
notBetween(Calendar start,
Calendar end,
DateTools.Resolution dateResolution)
note: supported resolutions are
DateTools.Resolution.YEAR ,
DateTools.Resolution.MONTH ,
DateTools.Resolution.DAY or
DateTools.Resolution.HOUR |
abstract Constraint |
notBetween(Object value1,
Object value2)
Adds a constraint that the value
fieldAttributeName is NOT between value1 and value2 ,
including NOT value1 and value2 |
abstract Constraint |
notContains(String fullTextSearch)
The negated version of
contains(String) |
abstract Constraint |
notEqualTo(Calendar value,
DateTools.Resolution dateResolution)
Case insensitive testing of
fieldAttributeName for some value . |
abstract Constraint |
notEqualTo(Object value)
Adds a constraint that the value
fieldAttributeName is NOT equal to value |
abstract Constraint |
notEqualToCaseInsensitive(String value)
note: supported resolutions are
DateTools.Resolution.YEAR ,
DateTools.Resolution.MONTH ,
DateTools.Resolution.DAY or
DateTools.Resolution.HOUR |
abstract Constraint |
notExists()
Add a constraint that the result does NOT have the property
fieldAttributeName |
abstract Constraint |
notLike(String value) |
static Constraint |
or(Constraint... constraints) |
public static FieldConstraintBuilder constraint(String fieldName)
fieldName
is in general a property name, for example example:title. Depending on the
filter method (equalTo(java.lang.Object)
, notEqualTo(java.lang.Object)
, contains(java.lang.String)
, etc)
the fieldName
is limited to certain conditions. For all ConstraintBuilder
constraints
methods the fieldName is allowed to be of the form myhippo:title or address/myhippo:street where the
latter is a constraint on a child node its property. There is one exception: When you use like(String)
or notLike(String)
, it is not allowed to do the constrain on a child node property.
For the constraint contains(String)
and notContains(String)
the
fieldName
can next to myhippo:title or address/myhippo:street also be equal to
"." meaning a text constraint on node scope (instead of property) level is done
If you do invoke an explicit ConstraintBuilder
method, for example equalTo(Object)
,
but the argument is null
, the effect is that this ConstraintBuilder
in HstQueryBuilder.where(Constraint)
is ignored. This way, when using the fluent api, you can skip null checks. For example
.where( constraint(".").contains(query) )will result in the constraint to be skipped if the
query
turns out to be null
.
fieldName
- the fieldName
this filter operates on, not allowed to be null
fieldName
public static Constraint and(Constraint... constraints)
public static Constraint or(Constraint... constraints)
public abstract Constraint equalTo(Object value)
fieldAttributeName
is equal to value
value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
. If
the parameter value
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
public abstract Constraint equalTo(Calendar value, DateTools.Resolution dateResolution)
Adds a constraint that the Calendar value for fieldAttributeName
rounded to its resolution is equal to the
rounded value for calendar
. Thus assume the Resolution
is equal to Resolution.DAY
,
then all nodes/documents where the property fieldAttributeName
as a Calendar value with the calendar
rounded to days, will match.
supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
value
- The Calendar
value constraint that the results should be equal to. If
the parameter value
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.dateResolution
- the resolution to use to compare dates. The higher the Resolution (year is highest) the better the performance.
supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
Constraint
public abstract Constraint equalToCaseInsensitive(String value)
fieldAttributeName
for some value
.value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
. If
the parameter value
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
same as equalTo(Object) only now the equality is checked
case insensitive and the value can only be of type String
public abstract Constraint notEqualTo(Object value)
fieldAttributeName
is NOT equal to value
value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
. If
the parameter value
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
public abstract Constraint notEqualTo(Calendar value, DateTools.Resolution dateResolution)
fieldAttributeName
for some value
.public abstract Constraint notEqualToCaseInsensitive(String value)
note: supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
. If
the parameter value
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
equalTo(java.util.Calendar, DateTools.Resolution) only now negated
public abstract Constraint greaterOrEqualThan(Object value)
Adds a constraint that the value fieldAttributeName
is greater than or equal to value
note that for range queries on calendar/date instances where the granularity of, say Day, is enough, you
should use greaterOrEqualThan(java.util.Calendar, DateTools.Resolution)
with the highest resolution that is acceptable for your use case, as this performs much better, OR make sure
that your application runs with a default resolution set to for example 'day'
value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
. If
the parameter value
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
public abstract Constraint greaterOrEqualThan(Calendar value, DateTools.Resolution dateResolution)
note: supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
value
- Calendar
object. If
the parameter value
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.dateResolution
- the resolution to use to compare dates. The higher the Resolution (year is highest) the better the performance.
supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
Constraint
between(java.util.Calendar, java.util.Calendar, DateTools.Resolution) but now no upper bound
public abstract Constraint greaterThan(Object value)
Adds a constraint that the value fieldAttributeName
is greater than value
note that for range queries on calendar/date instances where the granularity of, say Day, is enough, you
should use greaterThan(java.util.Calendar, org.hippoecm.repository.util.DateTools.Resolution)
with the highest resolution that is acceptable for your use case, as this performs much better, OR make sure
that your application runs with a default resolution set to for example 'day'
value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
. If
the parameter value
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
public abstract Constraint greaterThan(Calendar value, DateTools.Resolution dateResolution)
note: supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
value
- Calendar
object. If
the parameter value
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.dateResolution
- the resolution to use to compare dates. The higher the Resolution (year is highest) the better the performance.
supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
Constraint
between(java.util.Calendar, java.util.Calendar, DateTools.Resolution) but now no upper bound and lower bound not included
public abstract Constraint lessOrEqualThan(Object value)
Adds a constraint that the value fieldAttributeName
is less than or equal to value
note that for range queries on calendar/date instances where the granularity of, say Day, is enough, you
should use lessOrEqualThan(java.util.Calendar, org.hippoecm.repository.util.DateTools.Resolution)
with the highest resolution that is acceptable for your use case, as this performs much better, OR make sure
that your application runs with a default resolution set to for example 'day'
value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
. If
the parameter value
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
public abstract Constraint lessOrEqualThan(Calendar value, DateTools.Resolution dateResolution)
note: supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
public abstract Constraint lessThan(Object value)
Adds a constraint that the value fieldAttributeName
is less than value
note that for range queries on calendar/date instances where the granularity of, say Day, is enough, you
should use lessThan(java.util.Calendar, org.hippoecm.repository.util.DateTools.Resolution)
with the highest resolution that is acceptable for your use case, as this performs much better, OR make sure
that your application runs with a default resolution set to for example 'day'
value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
Constraint
public abstract Constraint lessThan(Calendar value, DateTools.Resolution dateResolution)
note: supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
value
- Calendar
object. If
the parameter value
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.dateResolution
- the resolution to use to compare dates. The higher the Resolution (year is highest) the better the performance.
supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
Constraint
between(java.util.Calendar, java.util.Calendar, DateTools.Resolution) but now no lower bound and upper bound not included
public abstract Constraint contains(String fullTextSearch)
scope
. When the
scope
is just a .
, the search will be done on the entire document. When the scope
is
for example @myproject:title
, the free text search is done on this property only. You can also point to properties of
child nodes, for example a scope like myproject:paragraph/@myproject:header
fullTextSearch
- the text to search on. If
the parameter fullTextSearch
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
public abstract Constraint notContains(String fullTextSearch)
contains(String)
fullTextSearch
- the text to search on. If
the parameter fullTextSearch
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
contains(String)
public abstract Constraint between(Object value1, Object value2)
Adds a constraint that the value fieldAttributeName
is between value1
and value2
(boundaries included).
note that for range queries on calendar/date instances where the granularity of, say Day, is enough, you
should use between(java.util.Calendar, java.util.Calendar, DateTools.Resolution)
with the highest resolution that is acceptable for your use case, as this performs much better, OR make sure
that your application runs with a default resolution set to for example 'day'
value1
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
. If
the parameter value1
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.value2
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
. If
the parameter value2
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
public abstract Constraint between(Calendar start, Calendar end, DateTools.Resolution dateResolution)
fieldAttributeName
is between start
and end
(boundaries included) BASED ON the
granularity resolution
. Thus suppose the Resolution is Resolution.DAY
, then results with the same DAY as value for fieldAttributeName
will be included. The higher the Resolution (year is highest) the better the performance!start
- the date to start from (including). If
the parameter start
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.end
- the date to end (including). If
the parameter end
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.dateResolution
- the resolution to use to compare dates. The higher the Resolution (year is highest) the better the performance.
supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
Constraint
public abstract Constraint notBetween(Object value1, Object value2)
Adds a constraint that the value fieldAttributeName
is NOT between value1
and value2
,
including NOT value1
and value2
note that for range queries on calendar/date instances where the granularity of, say Day, is enough, you
should use notBetween(java.util.Calendar, java.util.Calendar, DateTools.Resolution)
with the highest resolution that is acceptable for your use case, as this performs much better, OR make sure
that your application runs with a default resolution set to for example 'day'
value1
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
. If
the parameter value1
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.value2
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
. If
the parameter value2
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
public abstract Constraint notBetween(Calendar start, Calendar end, DateTools.Resolution dateResolution)
note: supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
start
- the date to start from (including). If
the parameter start
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.end
- the date to end (including). If
the parameter end
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.dateResolution
- the resolution to use to compare dates. The higher the Resolution (year is highest) the better the performance.
supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
Constraint
between(String, java.util.Calendar, java.util.Calendar, DateTools.Resolution) but now negated
public abstract Constraint like(String value)
This function is based on the LIKE predicate found in SQL. This method maps to jcr:like
as
jcr:like($property as attribute(), $pattern as xs:string)
. Also see JCR spec 1.0 6.6.5.1 jcr:like
usage: For example, the query “Find all documents whose myproject:title
property starts with
hip
”, is expressed as: addLike("myproject:title","hip%")
.
The %
after hip
is the wildcard.
This method is particularly helpful in key kind of fields, where the key values contain chars on which
Lucene text indexing tokenizes. For example, "give me all the documents that have a key that start with JIRA key
HSTTW0-23
" can be expressed as addLike("myproject:key","HSTTW0-23%")
.
This results in documents having key HSTTW0-2345
, HSTTW0-2357
, etc.
DO NOT USE '%' AS A PREFIX. Thus do not use a query like
addLike("myproject:key","%HSTTW0-23%")
. Note the prefix '%'. Prefix wildcards blow up in memory and CPU
as they cannot be efficiently done in Lucene.
value
- object that must be of type String. If
the parameter start
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
public abstract Constraint notLike(String value)
value
- object that must be of type String. If
the parameter start
is null
, this ConstraintBuilder
is ignored (unless another
constraint method is invoked without null
value.Constraint
only now inverted
public abstract Constraint exists()
fieldAttributeName
, regardless its valueConstraint
public abstract Constraint notExists()
fieldAttributeName
Constraint
public abstract Constraint jcrExpression(String jcrExpression)
jcrExpression
as constraint. See jsr-170 spec for the xpath formatjcrExpression
- the jcrExpression
to include in thisConstraint
Copyright © 2008–2016 Hippo B.V. (http://www.onehippo.com). All rights reserved.