Eval (query directive)
From WandoraWiki
Description
Evaluates a script. The script can do simple modifications to the input value or be arbitrarily complex.
The script context is initialized with three values. input contains the entire input row. context contains the query context, you can get the active topic map from it. val contains the active value of the input row.
The value on the last lime of the script is the return value of the script. it can be one of four things:
- A ResultIterator object which is returned as is as the result of the directive. It may be an empty iterator or iterate through any number of rows
- A ResultRow object which will be the single result row of the dirictive.
- An ArrayList containing ResultRow which will be converted to a ResultIterator iterating through the rows in the list.
- Any other object which will be added in the input row with the default column name.
In most cases the last option is sufficient and is by far the easiest to implement.
Constructor
Eval()
Examples
Following example selects base names of all instances of the input topic and adds the prefix "BaseName: " before each of them.
importPackage(org.wandora.query2); new Expr("\"BaseName: \"+val") .from(new BaseName()) .from(new Instances())