Package com.mendix.datastorage
Interface XPathQuery
- All Superinterfaces:
XPathBasicQuery
,XPathQueryBase
Fluent API for basic or schema-based XPath queries.
Can be used to create and execute XPath queries in a fluent manner. For example:
public List<IMendixObject> getObjectsWithValue(IContext context, ICore core, int value) {
List<IMendixObject> results = core.createXPathQuery("//Entity[attribute=$value]")
.setVariable("value", 1)
.setAmount(500)
.setOffset(50)
.setDepth(1)
.execute(context);
return results;
}
When not set, the defaults for amount and offset are -1, which means that all results will be retrieved. The default depth is 0, which means that ids of associated objects are retrieved, but not the associated objects themselves.
After the XPath query is built up, XPathQueryBase.execute(IContext)
can be called to retrieve the results.
- Since:
- Mendix 7.17
-
Method Summary
Modifier and TypeMethodDescriptionallowMathOperators
(boolean allowMathOperators) Enable or disable mathematical operators in the XPath query.setRetrievalSchema
(IRetrievalSchema schema) Adds a retrieval schema to the query.setVariable
(String name, boolean value) Sets a variable with a value of typeboolean
.setVariable
(String name, double value) Sets a variable with a value of typedouble
.setVariable
(String name, int value) Sets a variable with a value of typeint
.setVariable
(String name, long value) Sets a variable with a value of typelong
.setVariable
(String name, IMendixIdentifier identifier) Sets a variable with a value of typeIMendixIdentifier
.setVariable
(String name, IMendixObject object) Sets a variable with a value of typeIMendixObject
.setVariable
(String name, String value) Sets a variable with a value of typeString
.setVariable
(String name, BigDecimal value) Sets a variable with a value of typeBigDecimal
.setVariable
(String name, Collection<?> values) Sets a variable with a value of typeCollection
.Methods inherited from interface com.mendix.datastorage.XPathBasicQuery
addSort, setAmount, setDepth, setOffset
Methods inherited from interface com.mendix.datastorage.XPathQueryBase
execute, executeAggregateDouble, executeAggregateLong, executeRaw
-
Method Details
-
setRetrievalSchema
Adds a retrieval schema to the query.- Parameters:
schema
- the schema to apply- Returns:
- the instance of
XPathSchemaQuery
that can be used to construct an XPath query with schema
-
setVariable
Sets a variable with a value of typeBigDecimal
.- Specified by:
setVariable
in interfaceXPathBasicQuery
- Specified by:
setVariable
in interfaceXPathQueryBase
- Parameters:
name
- name of the variable referenced in the expression (without '$')value
- the value of the variable- Returns:
- the updated query instance
-
setVariable
Sets a variable with a value of typeboolean
.- Specified by:
setVariable
in interfaceXPathBasicQuery
- Specified by:
setVariable
in interfaceXPathQueryBase
- Parameters:
name
- name of the variable referenced in the expression (without '$')value
- the value of the variable- Returns:
- the updated query instance
-
setVariable
Sets a variable with a value of typedouble
.- Specified by:
setVariable
in interfaceXPathBasicQuery
- Specified by:
setVariable
in interfaceXPathQueryBase
- Parameters:
name
- name of the variable referenced in the expression (without '$')value
- the value of the variable- Returns:
- the updated query instance
-
setVariable
Sets a variable with a value of typeint
.- Specified by:
setVariable
in interfaceXPathBasicQuery
- Specified by:
setVariable
in interfaceXPathQueryBase
- Parameters:
name
- name of the variable referenced in the expression (without '$')value
- the value of the variable- Returns:
- the updated query instance
-
setVariable
Sets a variable with a value of typelong
.- Specified by:
setVariable
in interfaceXPathBasicQuery
- Specified by:
setVariable
in interfaceXPathQueryBase
- Parameters:
name
- name of the variable referenced in the expression (without '$')value
- the value of the variable- Returns:
- the updated query instance
-
setVariable
Sets a variable with a value of typeIMendixObject
.- Specified by:
setVariable
in interfaceXPathBasicQuery
- Specified by:
setVariable
in interfaceXPathQueryBase
- Parameters:
name
- name of the variable referenced in the expression (without '$')object
- aIMendixObject
value. Will be replaced by itsIMendixIdentifier
in the query.- Returns:
- the updated query instance
-
setVariable
Sets a variable with a value of typeIMendixIdentifier
.- Specified by:
setVariable
in interfaceXPathBasicQuery
- Specified by:
setVariable
in interfaceXPathQueryBase
- Parameters:
name
- name of the variable referenced in the expression (without '$')identifier
- the value of the variable- Returns:
- the updated query instance
-
setVariable
Sets a variable with a value of typeString
.- Specified by:
setVariable
in interfaceXPathBasicQuery
- Specified by:
setVariable
in interfaceXPathQueryBase
- Parameters:
name
- name of the variable referenced in the expression (without '$')value
- the value of the variable- Returns:
- the updated query instance
-
setVariable
Sets a variable with a value of typeCollection
.- Specified by:
setVariable
in interfaceXPathQueryBase
- Parameters:
name
- name of the variable referenced in the expression (without '$')values
- the value of the variable as a collection- Returns:
- the updated query instance
-
allowMathOperators
Enable or disable mathematical operators in the XPath query. By default, mathematical operators are not allowed.- Specified by:
allowMathOperators
in interfaceXPathBasicQuery
- Specified by:
allowMathOperators
in interfaceXPathQueryBase
- Parameters:
allowMathOperators
- sets whether mathematical operators should be allowed in the XPath query- Returns:
- the updated query instance
-