If (query directive)

From WandoraWiki
Revision as of 12:01, 20 August 2009 by Olli (Talk | contribs)

Jump to: navigation, search

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.