Class IfElseMacro
java.lang.Object
weka.core.expressionlanguage.common.IfElseMacro
- All Implemented Interfaces:
Macro
,MacroDeclarations
A macro declaration exposing the
ifelse
function.
The ifelse macro can be used as follows:
ifelse(condition, ifpart, elsepart)
Whith the following constraints:
- condition must be of boolean type
- ifpart and elsepart must be of the same type
- ifpart must be either of boolean, double or string type
ifelse(A < B, true, A = B)
ifelse(A = B, 4.0^2, 1/5)
ifelse(A > B, 'bigger', 'smaller')
- Version:
- $Revision: 1000 $
- Author:
- Benjamin Weber ( benweber at student dot ethz dot ch )
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
IfElseMacro
public IfElseMacro()
-
-
Method Details
-
hasMacro
Whether the macro is declared- Specified by:
hasMacro
in interfaceMacroDeclarations
- Parameters:
name
- name of the macro- Returns:
- whether the macro is declared
-
getMacro
Tries to fetch the macro The same invariant ofMacroDeclarations
applies here too.- Specified by:
getMacro
in interfaceMacroDeclarations
- Parameters:
name
- name of the macro- Returns:
- a macro
-
evaluate
Evaluates the ifelse macro- Specified by:
evaluate
in interfaceMacro
- Parameters:
params
- the parameters- Returns:
- an AST (abstract syntax tree) node evaluating the ifelse function
- Throws:
SemanticException
-