If (query directive)
From WandoraWiki
(Difference between revisions)
| Line 10: | Line 10: | ||
[[Category:Query directives]] | [[Category:Query directives]] | ||
| + | |||
| + | == Examples == | ||
| + | |||
| + | importPackage(org.wandora.query2); | ||
| + | new If( | ||
| + | new Exists(new Instances()), | ||
| + | new Literals("has instances"), | ||
| + | new Literals("no instances") | ||
| + | ) | ||
| + | |||
| + | This example returns a string "has instances" if the input topic has instances or "no instances" if it doesn't. | ||
Revision as of 11:01, 20 August 2009
Description
Returns results of one of two directives depending on the input. The conditional directive is given the input of this directive. If it returns a non empty result then the then directive is used. Otherwise the else directive is used if provided or an empty result is returned.
Constructor
If(Directive cond,Directive then,Directive else) - Depending on cond, returns the results of either then or else directive.
If(Directive cond,Directive then) - Depending on cond, returns the results of then directive or an empty result.
Examples
importPackage(org.wandora.query2);
new If(
new Exists(new Instances()),
new Literals("has instances"),
new Literals("no instances")
)
This example returns a string "has instances" if the input topic has instances or "no instances" if it doesn't.