====== Query expression ====== A query can be used as an expression if it is enclosed in asterisked parentheses ''(*'' and ''*)''. Theses symbols are also used to declare [[:01_user_documentation:07_rgg_xl:02_xl:03_query:04_context|context]] in a query but the concept is different. A query expression enables to execute the query in an imperative context (e.g. in a [[:01_user_documentation:07_rgg_xl:02_xl:02_java:01_java_block|java block]]). Thus, the query can be used combined with other imperative statements (e.g. methods, aggregators, ...). The query expression is a Node [[:01_user_documentation:07_rgg_xl:02_xl:08_object:04_generator|generator]] and can be used as such. Query expressions finds all matches of the pattern and yields the currently bound value of the right-most non-bracketed node pattern. ====== ====== The [[:01_user_documentation:07_rgg_xl:03_query_graph|model graph]] of such expression is defined implicitly based on the first enclosing declaration which has an annotation of the type [[https://javadoc.grogra.de/xl/de/grogra/xl/query/HasModel.html|@UseModel]]. The annotation takes an argument to specify a concrete class to use as compile time model. For instance: void run() { // java block (* ^ (>)* Node *); // this query expression is applied by the model graph of the enclosing method call } If we want to specify the current graph explicitly, it has to be prepended in front of the query as in graph.(* ^ (>)* Node *) // this query expression is applied by graph Then the current graph is the result of the prepended expression. The type of the expression has to be a subtype of [[https://javadoc.grogra.de/xl/de/grogra/xl/query/Graph.html|Graph]], and it has to have or inherit an annotation of type [[https://javadoc.grogra.de/xl/de/grogra/xl/query/HasModel.html|@HasModel]] whose single element specifies the corresponding compile-time model.