Class VariableDeclarationsCompositor
- java.lang.Object
-
- weka.core.expressionlanguage.common.VariableDeclarationsCompositor
-
- All Implemented Interfaces:
java.io.Serializable,VariableDeclarations
public class VariableDeclarationsCompositor extends java.lang.Object implements VariableDeclarations
A helper class that allows to combine several variable declarations together. It can be thought of as layering several scopes over one another. It will delegate thehasVariable(String)andgetVariable(String)methods to other variable declarations. Each variable declaration combined is checked in sequential order. No checks for conflicts are done. Thus shadowing is possible.- Version:
- $Revision: 1000 $
- Author:
- Benjamin Weber ( benweber at student dot ethz dot ch )
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description VariableDeclarationsCompositor(VariableDeclarations... declarations)Constructs aVariableDeclarationsCompositorcontaining the provided declarations
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NodegetVariable(java.lang.String name)Tries to fetch a variable from one of the combined declarations.booleanhasVariable(java.lang.String name)Whether the variable is contained in one of the combined declarations.
-
-
-
Constructor Detail
-
VariableDeclarationsCompositor
public VariableDeclarationsCompositor(VariableDeclarations... declarations)
Constructs aVariableDeclarationsCompositorcontaining the provided declarations The order of the declarations will determine the order of checking the declarations for variables.- Parameters:
declarations- the declarations being combined
-
-
Method Detail
-
hasVariable
public boolean hasVariable(java.lang.String name)
Whether the variable is contained in one of the combined declarations.- Specified by:
hasVariablein interfaceVariableDeclarations- Parameters:
name- name of the variable- Returns:
- whether the variable is contained in one of the combined declarations
-
getVariable
public Node getVariable(java.lang.String name)
Tries to fetch a variable from one of the combined declarations. The same invariant ofVariableDeclarationsapplies here too.- Specified by:
getVariablein interfaceVariableDeclarations- Parameters:
name- the name of the variable to be fetched- Returns:
- an AST (abstract syntax tree) node representing the variable
-
-