Interface XPathQuery

  • All Superinterfaces:
    XPathBasicQuery, XPathQueryBase

    public interface XPathQuery
    extends XPathQueryBase, XPathBasicQuery
    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 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;
     }
     

    After the XPath query is built up, XPathQueryBase.execute(IContext) can be called to retrieve the results.

    XPath string functions contains, starts-with and ends-with do not support variables as their second argument.

    Since:
    Mendix 7.17
    • Method Detail

      • setRetrievalSchema

        XPathSchemaQuery setRetrievalSchema​(IRetrievalSchema schema)
        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

        XPathQuery setVariable​(java.lang.String name,
                               java.math.BigDecimal value)
        Sets the value of the specified variable of type Decimal.
        Specified by:
        setVariable in interface XPathBasicQuery
        Specified by:
        setVariable in interface XPathQueryBase
        Parameters:
        name - the name of the variable to set
        value - the value to set
        Returns:
        the updated query
      • setVariable

        XPathQuery setVariable​(java.lang.String name,
                               boolean value)
        Sets the value of the specified variable of type Boolean.
        Specified by:
        setVariable in interface XPathBasicQuery
        Specified by:
        setVariable in interface XPathQueryBase
        Parameters:
        name - the name of the variable to set
        value - the value to set
        Returns:
        the updated query
      • setVariable

        XPathQuery setVariable​(java.lang.String name,
                               double value)
        Sets the value of the specified variable to type Decimal.
        Specified by:
        setVariable in interface XPathBasicQuery
        Specified by:
        setVariable in interface XPathQueryBase
        Parameters:
        name - the name of the variable to set
        value - the value to set
        Returns:
        the updated query
      • setVariable

        XPathQuery setVariable​(java.lang.String name,
                               int value)
        Sets the value of the specified variable of type Integer.
        Specified by:
        setVariable in interface XPathBasicQuery
        Specified by:
        setVariable in interface XPathQueryBase
        Parameters:
        name - the name of the variable to set
        value - the value to set
        Returns:
        the updated query
      • setVariable

        XPathQuery setVariable​(java.lang.String name,
                               long value)
        Sets the value of the specified variable of type Long.
        Specified by:
        setVariable in interface XPathBasicQuery
        Specified by:
        setVariable in interface XPathQueryBase
        Parameters:
        name - the name of the variable to set
        value - the value to set
        Returns:
        the updated query
      • setVariable

        XPathQuery setVariable​(java.lang.String name,
                               IMendixObject object)
        Sets the value of the specified variable of type (Mendix) Object.
        Specified by:
        setVariable in interface XPathBasicQuery
        Specified by:
        setVariable in interface XPathQueryBase
        Parameters:
        name - the name of the variable to set
        object - the value to set
        Returns:
        the updated query
      • setVariable

        XPathQuery setVariable​(java.lang.String name,
                               java.lang.String value)
        Sets the value of the specified variable of type String.
        Specified by:
        setVariable in interface XPathBasicQuery
        Specified by:
        setVariable in interface XPathQueryBase
        Parameters:
        name - the name of the variable to set
        value - the value to set
        Returns:
        the updated query
      • setVariable

        XPathQuery setVariable​(java.lang.String name,
                               java.util.Collection<?> values)
        Sets the value of the specified variable of type List.
        Specified by:
        setVariable in interface XPathQueryBase
        Parameters:
        name - the name of the variable to set
        values - the value to set
        Returns:
        the updated query