weka.core.expressionlanguage.common

## Class IfElseMacro

- java.lang.Object
- - weka.core.expressionlanguage.common.IfElseMacro

- All Implemented Interfaces:
    Macro, MacroDeclarations

      public class IfElseMacro
      extends java.lang.Object
      implements MacroDeclarations, Macro

  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
  Examples:
  - `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

    Constructors
    Constructor and Description
    `IfElseMacro()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Node` | `evaluate(Node... params)` Evaluates the ifelse macro
    `Macro` | `getMacro(java.lang.String name)` Tries to fetch the macro
    `boolean` | `hasMacro(java.lang.String name)` Whether the macro is declared

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### IfElseMacro

          public IfElseMacro()

  - ### Method Detail

    - #### hasMacro

          public boolean hasMacro(java.lang.String name)

      Whether the macro is declared
      Specified by:
        `hasMacro` in interface `MacroDeclarations`
      Parameters:
        `name` - name of the macro
      Returns:
        whether the macro is declared

    - #### getMacro

          public Macro getMacro(java.lang.String name)

      Tries to fetch the macro The same invariant of `MacroDeclarations` applies here too.
      Specified by:
        `getMacro` in interface `MacroDeclarations`
      Parameters:
        `name` - name of the macro
      Returns:
        a macro

    - #### evaluate

          public Node evaluate(Node... params)
                        throws SemanticException

      Evaluates the ifelse macro
      Specified by:
        `evaluate` in interface `Macro`
      Parameters:
        `params` - the parameters
      Returns:
        an AST (abstract syntax tree) node evaluating the ifelse function
      Throws:
        `SemanticException`