mln
Class Expression

java.lang.Object
  extended by mln.Expression

public class Expression
extends java.lang.Object

An expression to a function is like a literal to a predicate. The interesting part is that expressions can be nested. The value of an expression can be numeric/string/boolean.


Constructor Summary
Expression(Function func)
          Construct a new expression based on the function func_
 
Method Summary
 void addArgument(Expression expr)
          Append an argument to the underlying function
static Expression and(Expression e1, Expression e2)
          Boolean AND
 void bindVariables(java.util.Map<java.lang.String,java.lang.String> mapVarVal)
          Bind variable references to their values in the symbol table.
static Expression exprConstInteger(int n)
          Atomic expression representing a constant integer
static Expression exprConstNum(double num)
          Atomic expression representing a constant number
static Expression exprConstString(java.lang.String str)
          Atomic expression representing a constant string
static Expression exprVariableBinding(java.lang.String var)
          Atomic expression representing a variable binding
 java.util.HashSet<java.lang.String> getVars()
          Get the variables referenced by this expression.
 boolean isBoolean()
          Test if this expression returns a boolean value
 boolean isNumeric()
          Test if this expression returns a numeric value
 boolean isString()
          Test if this expression returns a string value
static Expression not(Expression e)
          Boolean negation
static Expression or(Expression e1, Expression e2)
          Boolean OR
 void renameVariables(java.util.Map<java.lang.String,java.lang.String> mapVarVar)
          Bind variable references to their values in the symbol table.
 java.lang.String toSQL()
          Get the SQL snippet for this expression
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Expression

public Expression(Function func)
Construct a new expression based on the function func_

Parameters:
func - the underlying function
Method Detail

addArgument

public void addArgument(Expression expr)
Append an argument to the underlying function

Parameters:
expr - the new argument

and

public static Expression and(Expression e1,
                             Expression e2)
Boolean AND

Parameters:
e1 -
e2 -

bindVariables

public void bindVariables(java.util.Map<java.lang.String,java.lang.String> mapVarVal)
Bind variable references to their values in the symbol table. Variable name in the clause -> attribute name in SQL representing the value column of the symbol table.

Parameters:
mapVarVal -

exprConstInteger

public static Expression exprConstInteger(int n)
Atomic expression representing a constant integer

Parameters:
n -

exprConstNum

public static Expression exprConstNum(double num)
Atomic expression representing a constant number


exprConstString

public static Expression exprConstString(java.lang.String str)
Atomic expression representing a constant string


exprVariableBinding

public static Expression exprVariableBinding(java.lang.String var)
Atomic expression representing a variable binding


getVars

public java.util.HashSet<java.lang.String> getVars()
Get the variables referenced by this expression.


isBoolean

public boolean isBoolean()
Test if this expression returns a boolean value


isNumeric

public boolean isNumeric()
Test if this expression returns a numeric value


isString

public boolean isString()
Test if this expression returns a string value


not

public static Expression not(Expression e)
Boolean negation

Parameters:
e -

or

public static Expression or(Expression e1,
                            Expression e2)
Boolean OR

Parameters:
e1 -
e2 -

renameVariables

public void renameVariables(java.util.Map<java.lang.String,java.lang.String> mapVarVar)
Bind variable references to their values in the symbol table. Variable name in the clause -> attribute name in SQL representing the value column of the symbol table.

Parameters:
mapVarVar -

toSQL

public java.lang.String toSQL()
Get the SQL snippet for this expression


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object