public class FilterImpl extends Object implements Filter
Constructor and Description |
---|
FilterImpl(javax.jcr.Session session,
DateTools.Resolution resolution) |
Modifier and Type | Method and Description |
---|---|
Filter |
addAndFilter(BaseFilter filter) |
void |
addBetween(String fieldAttributeName,
Calendar start,
Calendar end,
DateTools.Resolution resolution)
Adds a FAST DATE RANGE constraint that the Calendar value for
fieldAttributeName is between start and end (boundaries included) BASED ON the
granularity resolution . |
void |
addBetween(String fieldAttributeName,
Object value1,
Object value2)
Adds a constraint that the value
fieldAttributeName is between value1 and value2 (boundaries included). |
void |
addContains(String scope,
String fullTextSearch)
Adds a fulltext search to this Filter.
|
void |
addEqualTo(String fieldAttributeName,
Calendar calendar,
DateTools.Resolution resolution)
Adds a constraint that the Calendar value for
fieldAttributeName rounded to its resolution is equal to the
rounded value for calendar . |
void |
addEqualTo(String fieldAttributeName,
Object value)
Adds a constraint that the value
fieldAttributeName is equal to value |
void |
addEqualToCaseInsensitive(String fieldAttributeName,
String value)
Case insensitive testing of
fieldAttributeName for some value . |
void |
addGreaterOrEqualThan(String fieldAttributeName,
Calendar calendar,
DateTools.Resolution resolution)
note: supported resolutions are
DateTools.Resolution.YEAR ,
DateTools.Resolution.MONTH ,
DateTools.Resolution.DAY or
DateTools.Resolution.HOUR |
void |
addGreaterOrEqualThan(String fieldAttributeName,
Object value)
Adds a constraint that the value
fieldAttributeName is greater than or equal to value |
void |
addGreaterThan(String fieldAttributeName,
Calendar calendar,
DateTools.Resolution resolution)
note: supported resolutions are
DateTools.Resolution.YEAR ,
DateTools.Resolution.MONTH ,
DateTools.Resolution.DAY or
DateTools.Resolution.HOUR |
void |
addGreaterThan(String fieldAttributeName,
Object value)
Adds a constraint that the value
fieldAttributeName is greater than value |
void |
addIsNull(String fieldAttributeName)
Add a constraint that the result does NOT have the property
fieldAttributeName |
void |
addJCRExpression(String jcrExpression)
Adds the xpath
jcrExpression as constraint. |
void |
addLessOrEqualThan(String fieldAttributeName,
Calendar calendar,
DateTools.Resolution resolution)
note: supported resolutions are
DateTools.Resolution.YEAR ,
DateTools.Resolution.MONTH ,
DateTools.Resolution.DAY or
DateTools.Resolution.HOUR |
void |
addLessOrEqualThan(String fieldAttributeName,
Object value)
Adds a constraint that the value
fieldAttributeName is less than or equal to value |
void |
addLessThan(String fieldAttributeName,
Calendar calendar,
DateTools.Resolution resolution)
note: supported resolutions are
DateTools.Resolution.YEAR ,
DateTools.Resolution.MONTH ,
DateTools.Resolution.DAY or
DateTools.Resolution.HOUR |
void |
addLessThan(String fieldAttributeName,
Object value)
Adds a constraint that the value
fieldAttributeName is less than value |
void |
addLike(String fieldAttributeName,
Object value)
Deprecated.
|
void |
addLike(String fieldAttributeName,
String value)
This function is based on the LIKE predicate found in SQL.
|
void |
addNotBetween(String fieldAttributeName,
Calendar start,
Calendar end,
DateTools.Resolution resolution)
note: supported resolutions are
DateTools.Resolution.YEAR ,
DateTools.Resolution.MONTH ,
DateTools.Resolution.DAY or
DateTools.Resolution.HOUR |
void |
addNotBetween(String fieldAttributeName,
Object value1,
Object value2)
Adds a constraint that the value
fieldAttributeName is NOT between value1 and value2 ,
including NOT value1 and value2 |
void |
addNotContains(String scope,
String fullTextSearch)
The negated version of
Filter.addContains(String, String) |
void |
addNotEqualTo(String fieldAttributeName,
Calendar calendar,
DateTools.Resolution resolution)
note: supported resolutions are
DateTools.Resolution.YEAR ,
DateTools.Resolution.MONTH ,
DateTools.Resolution.DAY or
DateTools.Resolution.HOUR |
void |
addNotEqualTo(String fieldAttributeName,
Object value)
Adds a constraint that the value
fieldAttributeName is NOT equal to value |
void |
addNotEqualToCaseInsensitive(String fieldAttributeName,
String value)
Case insensitive testing of
fieldAttributeName for some value . |
void |
addNotLike(String fieldAttributeName,
Object value)
Deprecated.
|
void |
addNotLike(String fieldAttributeName,
String value) |
void |
addNotNull(String fieldAttributeName)
Add a constraint that the result does have the property
fieldAttributeName , regardless its value |
Filter |
addOrFilter(BaseFilter filter) |
String |
getJcrExpression() |
String |
getStringValue(Object value) |
Filter |
negate()
Negates the current filter
|
public FilterImpl(javax.jcr.Session session, DateTools.Resolution resolution)
resolution
- supported resolutions are DateTools.Resolution#YEAR
,
DateTools.Resolution#MONTH
,
DateTools.Resolution#DAY
or DateTools.Resolution#HOUR
public void addContains(String scope, String fullTextSearch) throws FilterException
Filter
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
addContains
in interface Filter
scope
- the scope to search in. scope = "."
means searching in the entire node/document. scope = "example:title"
only
searches in the property "example:title". scope
is also allowed to be a path to a property in a descendant node, for example scope = "address/example:street"
. The
latter is equivalent to scope = "address/@example:street"
fullTextSearch
- the text to search onFilterException
- when scope
or fullTextSearch
is null
public void addNotContains(String scope, String fullTextSearch) throws FilterException
Filter
Filter.addContains(String, String)
addNotContains
in interface Filter
scope
- the scope to search in. scope = "."
means searching in the entire node/document. scope = "example:title"
only
searches in the property "example:title". scope
is also allowed to be a path to a property in a descendant node, for example scope = "address/example:street"
. The
latter is equivalent to scope = "address/@example:street"
fullTextSearch
- the text to search onFilterException
- when scope
or fullTextSearch
is null
Filter.addContains(String, String)
public void addBetween(String fieldAttributeName, Object value1, Object value2) throws FilterException
Filter
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 Filter.addBetween(String, 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'
addBetween
in interface Filter
fieldAttributeName
- the name of the attribute, eg "hippo:lastModified"value1
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
value2
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
FilterException
- when fieldAttributeName
, value1
or value2
are invalid types/values or one of them is null
public void addBetween(String fieldAttributeName, Calendar start, Calendar end, DateTools.Resolution resolution) throws FilterException
Filter
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!addBetween
in interface Filter
fieldAttributeName
- the name of the attribute, eg "hippo:lastModified"start
- the date to start from (including)end
- the date to end (including)resolution
- 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
FilterException
public void addNotBetween(String fieldAttributeName, Object value1, Object value2) throws FilterException
Filter
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 Filter.addNotBetween(String, 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'
addNotBetween
in interface Filter
fieldAttributeName
- the name of the attribute, eg "example:date"value1
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
value2
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
FilterException
- when fieldAttributeName
, value1
or value2
are invalid types/values or one of them is null
public void addNotBetween(String fieldAttributeName, Calendar start, Calendar end, DateTools.Resolution resolution) throws FilterException
Filter
note: supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
addNotBetween
in interface Filter
FilterException
addBetween(String, java.util.Calendar, java.util.Calendar, DateTools.Resolution) but now negated
public void addEqualTo(String fieldAttributeName, Object value) throws FilterException
Filter
fieldAttributeName
is equal to value
addEqualTo
in interface Filter
fieldAttributeName
- the name of the attribute, eg "example:author"value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
FilterException
- when fieldAttributeName
or value
is of invalid type/value or is null
public void addEqualToCaseInsensitive(String fieldAttributeName, String value) throws FilterException
Filter
fieldAttributeName
for some value
.addEqualToCaseInsensitive
in interface Filter
FilterException
same as addEqualTo(String, Object) only now the equality is checked
case insensitive and the value can only be of type String
public void addEqualTo(String fieldAttributeName, Calendar calendar, DateTools.Resolution resolution) throws FilterException
Filter
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
addEqualTo
in interface Filter
FilterException
public void addNotEqualTo(String fieldAttributeName, Object value) throws FilterException
Filter
fieldAttributeName
is NOT equal to value
addNotEqualTo
in interface Filter
fieldAttributeName
- the name of the attribute, eg "example:author"value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
FilterException
- when fieldAttributeName
or value
is of invalid type/value or is null
public void addNotEqualToCaseInsensitive(String fieldAttributeName, String value) throws FilterException
Filter
fieldAttributeName
for some value
.addNotEqualToCaseInsensitive
in interface Filter
FilterException
same as addNotEqualTo(String, Object) only now the inequality is checked
case insensitive and the value can only be of type String
public void addNotEqualTo(String fieldAttributeName, Calendar calendar, DateTools.Resolution resolution) throws FilterException
Filter
note: supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
addNotEqualTo
in interface Filter
FilterException
addEqualTo(String, java.util.Calendar, DateTools.Resolution) only now negated
public void addGreaterOrEqualThan(String fieldAttributeName, Object value) throws FilterException
Filter
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 Filter.addGreaterOrEqualThan(String, 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'
addGreaterOrEqualThan
in interface Filter
fieldAttributeName
- the name of the attribute, eg "example:date"value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
FilterException
- when fieldAttributeName
or value
is of invalid type/value or is null
public void addGreaterOrEqualThan(String fieldAttributeName, Calendar calendar, DateTools.Resolution resolution) throws FilterException
Filter
note: supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
addGreaterOrEqualThan
in interface Filter
FilterException
addBetween(String, java.util.Calendar, java.util.Calendar, DateTools.Resolution) but now no upper bound
public void addGreaterThan(String fieldAttributeName, Object value) throws FilterException
Filter
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 Filter.addGreaterThan(String, 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'
addGreaterThan
in interface Filter
fieldAttributeName
- the name of the attribute, eg "example:date"value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
FilterException
- when fieldAttributeName
or value
is of invalid type/value or is null
public void addGreaterThan(String fieldAttributeName, Calendar calendar, DateTools.Resolution resolution) throws FilterException
Filter
note: supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
addGreaterThan
in interface Filter
FilterException
addBetween(String, java.util.Calendar, java.util.Calendar, DateTools.Resolution) but now no upper bound and lower bound not included
public void addLessOrEqualThan(String fieldAttributeName, Object value) throws FilterException
Filter
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 Filter.addLessOrEqualThan(String, 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'
addLessOrEqualThan
in interface Filter
fieldAttributeName
- the name of the attribute, eg "example:date"value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
FilterException
- when fieldAttributeName
or value
is of invalid type/value or is null
public void addLessOrEqualThan(String fieldAttributeName, Calendar calendar, DateTools.Resolution resolution) throws FilterException
Filter
note: supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
addLessOrEqualThan
in interface Filter
FilterException
addBetween(String, java.util.Calendar, java.util.Calendar, DateTools.Resolution) but now no lower bound
public void addLessThan(String fieldAttributeName, Object value) throws FilterException
Filter
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 Filter.addLessThan(String, 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'
addLessThan
in interface Filter
fieldAttributeName
- the name of the attribute, eg "example:date"value
- object that must be of type String, Boolean, Long, Double, Calendar
or Date
FilterException
- when fieldAttributeName
or value
is of invalid type/value or is null
public void addLessThan(String fieldAttributeName, Calendar calendar, DateTools.Resolution resolution) throws FilterException
Filter
note: supported resolutions are
DateTools.Resolution.YEAR
,
DateTools.Resolution.MONTH
,
DateTools.Resolution.DAY
or
DateTools.Resolution.HOUR
addLessThan
in interface Filter
FilterException
addBetween(String, java.util.Calendar, java.util.Calendar, DateTools.Resolution) but now no lower bound and upper bound not included
@Deprecated public void addLike(String fieldAttributeName, Object value) throws FilterException
addLike
in interface Filter
FilterException
Filter.addLike(String, String)
public void addLike(String fieldAttributeName, String value) throws FilterException
Filter
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.
addLike
in interface Filter
fieldAttributeName
- the name of the attribute, eg "example:author"value
- object that must be of type StringFilterException
- when fieldAttributeName
or value
is of invalid type/value or is null
public void addNotLike(String fieldAttributeName, String value) throws FilterException
addNotLike
in interface Filter
FilterException
only now inverted
@Deprecated public void addNotLike(String fieldAttributeName, Object value) throws FilterException
addNotLike
in interface Filter
FilterException
only now inverted
public void addNotNull(String fieldAttributeName) throws FilterException
Filter
fieldAttributeName
, regardless its valueaddNotNull
in interface Filter
fieldAttributeName
- the name of the attribute, eg "example:author"FilterException
- when fieldAttributeName
is null
public void addIsNull(String fieldAttributeName) throws FilterException
Filter
fieldAttributeName
addIsNull
in interface Filter
fieldAttributeName
- the name of the attribute, eg "example:author"FilterException
- when fieldAttributeName
is null
public void addJCRExpression(String jcrExpression)
Filter
jcrExpression
as constraint. See jsr-170 spec for the xpath formataddJCRExpression
in interface Filter
public Filter addOrFilter(BaseFilter filter)
addOrFilter
in interface Filter
filter
- to OR addedpublic Filter addAndFilter(BaseFilter filter)
addAndFilter
in interface Filter
filter
- to AND addedpublic String getJcrExpression()
getJcrExpression
in interface BaseFilter
public String getStringValue(Object value) throws FilterException
FilterException
Copyright © 2008–2016 Hippo B.V. (http://www.onehippo.com). All rights reserved.