Class Criterion
- All Implemented Interfaces:
HasHandlers
- Direct Known Subclasses:
AdvancedCriteria
A criterion is part of the definition of an AdvancedCriteria
object, which is used to filter records according to search criteria.
A
criterion consists of an operator
and typically a fieldName
from a Record
and a value
to compare to. However some operators either don't require a value
(eg, isNull) or act on other criteria rather than directly on a Record
's fields (eg,
the "and" and "or" logical operators). Also, it is possible to specify a fieldQuery
instead of a fieldName
and/or a valueQuery
instead of a value
A shortcut form is also
allowed where only fieldName
and value
values are provided. In this case the
operator
is assumed to be "equals".
- See Also:
-
Field Summary
Fields inherited from class com.smartgwt.client.core.DataClass
factoryCreated, factoryProperties
-
Constructor Summary
ConstructorDescriptionCriterion
(JavaScriptObject jsObj) Criterion
(OperatorId operator) Criterion
(OperatorId operator, Criterion[] criterias) Criterion
(String fieldName, OperatorId operator) Criterion
(String fieldName, OperatorId operator, RelativeDate value) Constructor for Criterion with fieldName, operator and RelativeDate value.Criterion
(String fieldName, OperatorId operator, RelativeDate start, RelativeDate end) Constructor for Criterion with fieldName, operator, start and end RelativeDate values.Criterion
(String fieldName, OperatorId operator, Boolean value) Constructor for Criterion with fieldName, operator and value.Criterion
(String fieldName, OperatorId operator, Boolean[] value) Criterion
(String fieldName, OperatorId operator, Float value) Constructor for Criterion with fieldName, operator and value.Criterion
(String fieldName, OperatorId operator, Float[] value) Criterion
(String fieldName, OperatorId operator, Float start, Float end) Constructor for Criterion with fieldName, operator, start and end values.Criterion
(String fieldName, OperatorId operator, Integer value) Constructor for Criterion with fieldName, operator and value.Criterion
(String fieldName, OperatorId operator, Integer[] value) Criterion
(String fieldName, OperatorId operator, Integer start, Integer end) Constructor for Criterion with fieldName, operator, start and end values.Criterion
(String fieldName, OperatorId operator, Long value) Constructor for Criterion with fieldName, operator and value.Criterion
(String fieldName, OperatorId operator, Long[] value) Criterion
(String fieldName, OperatorId operator, Long start, Long end) Constructor for Criterion with fieldName, operator, start and end values.Criterion
(String fieldName, OperatorId operator, String value) Constructor for Criterion with fieldName, operator and value.Criterion
(String fieldName, OperatorId operator, String[] value) Criterion
(String fieldName, OperatorId operator, String start, String end) Constructor for Criterion with fieldName, operator, start and end values.Criterion
(String fieldName, OperatorId operator, Date value) Constructor for Criterion with fieldName, operator and value.Criterion
(String fieldName, OperatorId operator, Date[] value) Criterion
(String fieldName, OperatorId operator, Date start, Date end) Constructor for Criterion with fieldName, operator, start and end values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new criteria.void
Adds a new criteria.void
addCriteria
(String field) This method callsaddCriteria(String, OperatorId, value)
, passing "EQUALS" as the OperatorId and Boolean.TRUE as value.void
addCriteria
(String field, OperatorId op, Boolean value) This method is similar toaddCriteria(String, OperatorId, String)
.void
addCriteria
(String field, OperatorId op, Boolean[] value) This method is similar toaddCriteria(String, OperatorId, String)
.void
addCriteria
(String field, OperatorId op, Float value) This method is similar toaddCriteria(String, OperatorId, String)
.void
addCriteria
(String field, OperatorId op, Float[] value) This method is similar toaddCriteria(String, OperatorId, String)
.void
addCriteria
(String field, OperatorId op, Integer value) This method is similar toaddCriteria(String, OperatorId, String)
.void
addCriteria
(String field, OperatorId op, Integer[] value) This method is similar toaddCriteria(String, OperatorId, String)
.void
addCriteria
(String field, OperatorId op, String value) Creates a Criterion and callsaddCriteria(Criterion)
.void
addCriteria
(String field, OperatorId op, String[] value) This method is similar toaddCriteria(String, OperatorId, String)
.void
addCriteria
(String field, OperatorId op, Date value) This method is similar toaddCriteria(String, OperatorId, String)
.void
addCriteria
(String field, OperatorId op, Date[] value) This method is similar toaddCriteria(String, OperatorId, String)
.void
addCriteria
(String field, Boolean value) This method is similar toaddCriteria(String, String)
.void
addCriteria
(String field, Boolean[] value) This method is similar toaddCriteria(String, String)
.void
addCriteria
(String field, Float value) This method is similar toaddCriteria(String, String)
.void
addCriteria
(String field, Float[] value) This method is similar toaddCriteria(String, String)
.void
addCriteria
(String field, Integer value) This method is similar toaddCriteria(String, String)
.void
addCriteria
(String field, Integer[] value) This method is similar toaddCriteria(String, String)
.void
addCriteria
(String field, String value) This method callsaddCriteria(String, OperatorId, String)
, passing "EQUALS" as the OperatorId.void
addCriteria
(String field, String[] value) This method is similar toaddCriteria(String, String)
.void
addCriteria
(String field, Date value) This method is similar toaddCriteria(String, String)
.void
addCriteria
(String field, Date[] value) This method is similar toaddCriteria(String, String)
.void
For a Criterion that usesOperatorId.AND
orOperatorId.OR
, add an additional Criterion to the list of subcriteria to be evaluated.Returns an AdvancedCriteria derived from this Criteria object.void
buildCriterionFromList
(OperatorId operator, Criterion[] criterias) For a criterion with an operator that acts on other criteria (eg "and", "or"), a list of sub-criteria that are grouped together by the operator.Name of the field in eachRecord
that this criterion applies to.A subquery to use instead of afieldName
.Operator this criterion applies.static Criterion
getOrCreateRef
(JavaScriptObject jsObj) Retrieves the specified value for this criterion.Retrieves the specified value for this criterion.Retrieves the specified value for this criterion.final Integer
Synonym ofgetValueAsInteger()
.int[]
Retrieves the specified value for this criterion.Retrieves the specified value for this criterion.Retrieves the specified value for this criterion.String[]
Retrieves the specified value for this criterion.WhereverDynamicCriteria
are supported,valuePath
can be specified as a path in the currentCanvas.ruleScope
as an alternative to setting a fixedvalue
.A subquery to use instead of avalue
.static final boolean
instanceOf
(Object object) void
setCriteria
(Criterion... criteria) For a criterion with an operator that acts on other criteria (eg "and", "or"), a list of sub-criteria that are grouped together by the operator.void
setCustomOperator
(String operator) Specifies a "custom" operator to this criterion.setFieldName
(String fieldName) Name of the field in eachRecord
that this criterion applies to.setFieldQuery
(AdvancedCriterionSubquery fieldQuery) A subquery to use instead of afieldName
.setOperator
(OperatorId operator) Operator this criterion applies.setValuePath
(String valuePath) WhereverDynamicCriteria
are supported,valuePath
can be specified as a path in the currentCanvas.ruleScope
as an alternative to setting a fixedvalue
.setValueQuery
(AdvancedCriterionSubquery valueQuery) A subquery to use instead of avalue
.void
Methods inherited from class com.smartgwt.client.data.Criteria
addCriteria, addCriteria, addCriteria, addCriteria, addCriteria, convertToCriteriaArray, getValues, isAdvanced
Methods inherited from class com.smartgwt.client.core.DataClass
applyFactoryProperties, doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, isFactoryCreated, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeAsJavaObject, setFactoryCreated
-
Constructor Details
-
Criterion
public Criterion() -
Criterion
-
Criterion
-
Criterion
-
Criterion
-
Criterion
-
Criterion
-
Criterion
-
Criterion
Constructor for Criterion with fieldName, operator and value.- Parameters:
fieldName
- the field nameoperator
- the operatorvalue
- the value
-
Criterion
Constructor for Criterion with fieldName, operator, start and end values. This constructor is only valid when the operator isOperatorId.BETWEEN
orOperatorId.BETWEEN_INCLUSIVE
- Parameters:
fieldName
- the field nameoperator
- the operatorstart
- the start valueend
- the end value
-
Criterion
Constructor for Criterion with fieldName, operator and value.- Parameters:
fieldName
- the field nameoperator
- the operatorvalue
- the value
-
Criterion
Constructor for Criterion with fieldName, operator, start and end values. This constructor is only valid when the operator isOperatorId.BETWEEN
orOperatorId.BETWEEN_INCLUSIVE
- Parameters:
fieldName
- the field nameoperator
- the operatorstart
- the start valueend
- the end value
-
Criterion
Constructor for Criterion with fieldName, operator and value.- Parameters:
fieldName
- the field nameoperator
- the operatorvalue
- the value
-
Criterion
Constructor for Criterion with fieldName, operator, start and end values. This constructor is only valid when the operator isOperatorId.BETWEEN
orOperatorId.BETWEEN_INCLUSIVE
- Parameters:
fieldName
- the field nameoperator
- the operatorstart
- the start valueend
- the end value
-
Criterion
Constructor for Criterion with fieldName, operator and value.- Parameters:
fieldName
- the field nameoperator
- the operatorvalue
- the value
-
Criterion
Constructor for Criterion with fieldName, operator, start and end values. This constructor is only valid when the operator isOperatorId.BETWEEN
orOperatorId.BETWEEN_INCLUSIVE
- Parameters:
fieldName
- the field nameoperator
- the operatorstart
- the start valueend
- the end value
-
Criterion
Constructor for Criterion with fieldName, operator and RelativeDate value.- Parameters:
fieldName
- the field nameoperator
- the operatorvalue
- the RelativeDate value
-
Criterion
Constructor for Criterion with fieldName, operator, start and end RelativeDate values. This constructor is only valid when the operator isOperatorId.BETWEEN
orOperatorId.BETWEEN_INCLUSIVE
- Parameters:
fieldName
- the field nameoperator
- the operatorstart
- the start valueend
- the end value
-
Criterion
Constructor for Criterion with fieldName, operator and value.- Parameters:
fieldName
- the field nameoperator
- the operatorvalue
- the value
-
Criterion
Constructor for Criterion with fieldName, operator and value. Note that JavaScript does not natively have an equivalent format to Java long (fixed point 64 bit). As such the value passed in will be converted to a double value for storage.- Parameters:
fieldName
- the field nameoperator
- the operatorvalue
- the value
-
Criterion
Constructor for Criterion with fieldName, operator, start and end values. This constructor is only valid when the operator isOperatorId.BETWEEN
orOperatorId.BETWEEN_INCLUSIVE
- Parameters:
fieldName
- the field nameoperator
- the operatorstart
- the start valueend
- the end value
-
Criterion
-
Criterion
-
Criterion
-
Criterion
-
Criterion
-
Criterion
-
-
Method Details
-
getOrCreateRef
-
setCriteria
For a criterion with an operator that acts on other criteria (eg "and", "or"), a list of sub-criteria that are grouped together by the operator.- Parameters:
criteria
- New criteria value. Default value is null- Returns:
Criterion
instance, for chaining setter calls- See Also:
-
getCriteria
For a criterion with an operator that acts on other criteria (eg "and", "or"), a list of sub-criteria that are grouped together by the operator.- Returns:
- Current criteria value. Default value is null
- See Also:
-
setFieldName
Name of the field in eachRecord
that this criterion applies to. Not applicable for a criterion withsub-criteria
. Can be specified as a dataPath to allow matching nested objects. Use '/' as delimiters for dataPath. SeedataPath
for more information.fieldQuery
shortcutsfieldName
can also be used to express a compact form of related-field filtering. If you set this property to the qualified name of a field on a related DataSource, it will be transformed into a basicAdvancedCriterionSubquery
. For example, say you have anOrder
dataSource, which has aforeign key relation
to yourCustomer
dataSource, and yourCustomer
dataSource has a "region" field. If you wanted to fetch all Orders for Customers in the EMEA region, you could declare criteria like this:{fieldName: "Customer.region", operator: "equals", value: "EMEA"}
This would be transformed into a subquery filter that would select only the records you want:{ fieldQuery: { dataSource: "Customer", queryOutput: "region" }, operator: "equals", value: "EMEA" }
This transformation takes place before the filtering subsystem even sees the criteria, so declaring the shortcut form viafieldName
leads to exactly the same filtering behavior as if you specified the subquery directly as afieldQuery
See the
AdvancedCriterionSubquery
overview linked above for more details of the extremely powerful subquery filtering options.- Parameters:
fieldName
- New fieldName value. Default value is null- Returns:
Criterion
instance, for chaining setter calls- See Also:
-
getFieldName
Name of the field in eachRecord
that this criterion applies to. Not applicable for a criterion withsub-criteria
. Can be specified as a dataPath to allow matching nested objects. Use '/' as delimiters for dataPath. SeedataPath
for more information.fieldQuery
shortcutsfieldName
can also be used to express a compact form of related-field filtering. If you set this property to the qualified name of a field on a related DataSource, it will be transformed into a basicAdvancedCriterionSubquery
. For example, say you have anOrder
dataSource, which has aforeign key relation
to yourCustomer
dataSource, and yourCustomer
dataSource has a "region" field. If you wanted to fetch all Orders for Customers in the EMEA region, you could declare criteria like this:{fieldName: "Customer.region", operator: "equals", value: "EMEA"}
This would be transformed into a subquery filter that would select only the records you want:{ fieldQuery: { dataSource: "Customer", queryOutput: "region" }, operator: "equals", value: "EMEA" }
This transformation takes place before the filtering subsystem even sees the criteria, so declaring the shortcut form viafieldName
leads to exactly the same filtering behavior as if you specified the subquery directly as afieldQuery
See the
AdvancedCriterionSubquery
overview linked above for more details of the extremely powerful subquery filtering options.- Returns:
- Current fieldName value. Default value is null
- See Also:
-
setFieldQuery
A subquery to use instead of afieldName
. When you use afieldQuery
instead of afieldName
, you are comparing the criterionvalue
to the result of running a per-record subquery, rather than a field value found directly on the record. Note, it is also possible to specify both afieldQuery
and avalueQuery
.See the
subquery overview
for more details of the criteria subquery feature, and examples of use.Note, if you specify both
fieldQuery
andfieldName
in a criterion, we use thefieldName
and thefieldQuery
is ignored.Note also that
fieldName
supports a special shortcut syntax for declaring afieldQuery
as a simple qualified reference to a related field. See thefieldName
doc linked above for details- Parameters:
fieldQuery
- New fieldQuery value. Default value is null- Returns:
Criterion
instance, for chaining setter calls- See Also:
-
getFieldQuery
A subquery to use instead of afieldName
. When you use afieldQuery
instead of afieldName
, you are comparing the criterionvalue
to the result of running a per-record subquery, rather than a field value found directly on the record. Note, it is also possible to specify both afieldQuery
and avalueQuery
.See the
subquery overview
for more details of the criteria subquery feature, and examples of use.Note, if you specify both
fieldQuery
andfieldName
in a criterion, we use thefieldName
and thefieldQuery
is ignored.Note also that
fieldName
supports a special shortcut syntax for declaring afieldQuery
as a simple qualified reference to a related field. See thefieldName
doc linked above for details- Returns:
- Current fieldQuery value. Default value is null
- See Also:
-
setOperator
Operator this criterion applies.- Parameters:
operator
- New operator value. Default value is null- Returns:
Criterion
instance, for chaining setter calls- See Also:
-
getOperator
Operator this criterion applies.- Returns:
- Current operator value. Default value is null
- See Also:
-
setValuePath
WhereverDynamicCriteria
are supported,valuePath
can be specified as a path in the currentCanvas.ruleScope
as an alternative to setting a fixedvalue
.Note:
valuePath
vs setting a path forfieldName
:- use a path for
criterion.fieldName
when criteria will be matched against a nested data structure. - use
criterion.valuePath
when the values used in filtering should be dynamically derived based on theCanvas.ruleScope
. This does not imply that the criteria will be matched against a nested structure.
- Parameters:
valuePath
- New valuePath value. Default value is null- Returns:
Criterion
instance, for chaining setter calls
- use a path for
-
getValuePath
WhereverDynamicCriteria
are supported,valuePath
can be specified as a path in the currentCanvas.ruleScope
as an alternative to setting a fixedvalue
.Note:
valuePath
vs setting a path forfieldName
:- use a path for
criterion.fieldName
when criteria will be matched against a nested data structure. - use
criterion.valuePath
when the values used in filtering should be dynamically derived based on theCanvas.ruleScope
. This does not imply that the criteria will be matched against a nested structure.
- Returns:
- Current valuePath value. Default value is null
- use a path for
-
setValueQuery
A subquery to use instead of avalue
. When you use avalueQuery
instead of avalue
, you are comparing the values in the record field named in the criterionfieldName
to the result of running a per-record subquery, rather than a literal scalar value. . Note, it is also possible to specify both avalueQuery
and afieldQuery
.See the
subquery overview
for more details of the criteria subquery feature, and examples of use.Note, if you specify both
valueQuery
andvalue
in a criterion, we use thevalue
and thevalueQuery
is ignored- Parameters:
valueQuery
- New valueQuery value. Default value is null- Returns:
Criterion
instance, for chaining setter calls- See Also:
-
getValueQuery
A subquery to use instead of avalue
. When you use avalueQuery
instead of avalue
, you are comparing the values in the record field named in the criterionfieldName
to the result of running a per-record subquery, rather than a literal scalar value. . Note, it is also possible to specify both avalueQuery
and afieldQuery
.See the
subquery overview
for more details of the criteria subquery feature, and examples of use.Note, if you specify both
valueQuery
andvalue
in a criterion, we use thevalue
and thevalueQuery
is ignored- Returns:
- Current valueQuery value. Default value is null
- See Also:
-
instanceOf
-
addCriteria
Adds a new criteria.If the present criteria operation is "and", the new criteria is appended to the criteria list.
Otherwise, the existing criteria is replaced with an "and" criteria, with two sub-criteria: the existing criteria, and the passed criteria.
Note that if the existing criteria was empty (as would happen if new AdvancedCriteria() were called with no arguments), an "and" operator will still be introduced, but the passed criteria will be the only sub-criteria.
To add an additional Criterion when using the "or" operator, use
appendToCriterionList(com.smartgwt.client.data.Criterion)
.- Parameters:
c
- the passed criteria object
-
addCriteria
Adds a new criteria. If the passed criteria is a simple Criteria or Criterion, it will turn into AdvancedCriteria, and will be added to the existent criteria.- Overrides:
addCriteria
in classCriteria
- Parameters:
c
- the passed criteria object
-
addCriteria
This method callsaddCriteria(String, OperatorId, value)
, passing "EQUALS" as the OperatorId and Boolean.TRUE as value.- See Also:
-
addCriteria
This method callsaddCriteria(String, OperatorId, String)
, passing "EQUALS" as the OperatorId.- Overrides:
addCriteria
in classCriteria
- See Also:
-
addCriteria
This method is similar toaddCriteria(String, String)
.- Overrides:
addCriteria
in classCriteria
-
addCriteria
This method is similar toaddCriteria(String, String)
.- Overrides:
addCriteria
in classCriteria
-
addCriteria
This method is similar toaddCriteria(String, String)
.- Overrides:
addCriteria
in classCriteria
-
addCriteria
This method is similar toaddCriteria(String, String)
.- Overrides:
addCriteria
in classCriteria
-
addCriteria
This method is similar toaddCriteria(String, String)
.- Overrides:
addCriteria
in classCriteria
-
addCriteria
This method is similar toaddCriteria(String, String)
.- Overrides:
addCriteria
in classCriteria
-
addCriteria
This method is similar toaddCriteria(String, String)
.- Overrides:
addCriteria
in classCriteria
-
addCriteria
This method is similar toaddCriteria(String, String)
. -
addCriteria
This method is similar toaddCriteria(String, String)
.- Overrides:
addCriteria
in classCriteria
-
addCriteria
Creates a Criterion and callsaddCriteria(Criterion)
. -
addCriteria
This method is similar toaddCriteria(String, OperatorId, String)
. -
addCriteria
This method is similar toaddCriteria(String, OperatorId, String)
. -
addCriteria
This method is similar toaddCriteria(String, OperatorId, String)
. -
addCriteria
This method is similar toaddCriteria(String, OperatorId, String)
. -
addCriteria
This method is similar toaddCriteria(String, OperatorId, String)
. -
addCriteria
This method is similar toaddCriteria(String, OperatorId, String)
. -
addCriteria
This method is similar toaddCriteria(String, OperatorId, String)
. -
addCriteria
This method is similar toaddCriteria(String, OperatorId, String)
. -
addCriteria
This method is similar toaddCriteria(String, OperatorId, String)
. -
buildCriterionFromList
-
appendToCriterionList
For a Criterion that usesOperatorId.AND
orOperatorId.OR
, add an additional Criterion to the list of subcriteria to be evaluated. -
setCustomOperator
Specifies a "custom" operator to this criterion.- Parameters:
operator
- the operator
-
markAdvancedCriteria
public void markAdvancedCriteria() -
unmarkAdvancedCriteria
public void unmarkAdvancedCriteria() -
getValueAsString
Retrieves the specified value for this criterion. Only applies to criterion where operator and value have been specified - will not apply to criterion containing {@link #getCriteria(),sub criteria}.- Returns:
-
getValueAsInt
Synonym ofgetValueAsInteger()
. -
getValueAsInteger
Retrieves the specified value for this criterion. Only applies to criterion where operator and value have been specified - will not apply to criterion containing {@link #getCriteria(),sub criteria}.- Returns:
-
getValueAsFloat
Retrieves the specified value for this criterion. Only applies to criterion where operator and value have been specified - will not apply to criterion containing {@link #getCriteria(),sub criteria}.- Returns:
-
getValueAsDate
Retrieves the specified value for this criterion. Only applies to criterion where operator and value have been specified - will not apply to criterion containing {@link #getCriteria(),sub criteria}.- Returns:
-
getValueAsBoolean
Retrieves the specified value for this criterion. Only applies to criterion where operator and value have been specified - will not apply to criterion containing {@link #getCriteria(),sub criteria}.- Returns:
-
getValueAsStringArray
Retrieves the specified value for this criterion. Only applies to criterion where operator and value have been specified - will not apply to criterion containing {@link #getCriteria(),sub criteria}.- Returns:
-
getValueAsIntArray
public int[] getValueAsIntArray()Retrieves the specified value for this criterion. Only applies to criterion where operator and value have been specified - will not apply to criterion containing {@link #getCriteria(),sub criteria}.- Returns:
-
asAdvancedCriteria
Returns an AdvancedCriteria derived from this Criteria object.- Overrides:
asAdvancedCriteria
in classCriteria
- Returns:
-