Package com.Lomikel.DB
Class Evaluator
- java.lang.Object
-
- com.Lomikel.DB.Evaluator
-
- Direct Known Subclasses:
GremlinEvaluator
,HBaseEvaluator
public class Evaluator extends java.lang.Object
Evaluator
evaluates formulas.- Author:
- J.Hrivnac
-
-
Field Summary
Fields Modifier and Type Field Description private Interpreter
_interpreter
private Schema
_schema
private java.util.Set<java.lang.String>
_variables
private static org.apache.logging.log4j.Logger
log
Logging .
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
eval(java.util.Map<java.lang.String,java.lang.String> values, java.lang.String formula, java.lang.String type)
Evaluate formula with supplied variables and values.boolean
evalBoolean(java.util.Map<java.lang.String,java.lang.String> values, java.lang.String formula)
Evaluate boolean formula with supplied variables and values.double
evalDouble(java.util.Map<java.lang.String,java.lang.String> values, java.lang.String formula)
Evaluate double formula with supplied variables and values.void
forceVariables(java.lang.String variables)
Add variables to the list of used variables.boolean
hasVariable(java.lang.String var)
Shows whether a variable exists.static double
qdistance0(double v1, double v2, double v3, double v4)
void
setEvaluatorFunctions(java.lang.String javaEF, java.lang.String bshEF)
Set Java and BeanShell Evaluator Functions.void
setVariable(java.lang.String name)
Declare variable.void
setVariable(java.lang.String name, double value)
TBDvoid
setVariable(java.lang.String name, double[] values)
TBDvoid
setVariable(java.lang.String name, java.lang.String value)
Set variable.void
setVariable(java.lang.String name, java.lang.String[] values)
Set array variable.void
setVariables(java.lang.String formula)
Add variables to the list of used variables.java.lang.String[]
variables()
Give the array of used variables.protected java.lang.String
varName(java.lang.String fullName)
Give variable name from the database name.
-
-
-
Field Detail
-
_variables
private java.util.Set<java.lang.String> _variables
-
_interpreter
private Interpreter _interpreter
-
log
private static org.apache.logging.log4j.Logger log
Logging .
-
-
Constructor Detail
-
Evaluator
public Evaluator(Schema schema) throws LomikelException
Create.- Parameters:
schema
- TheSchema
to use to interpret types.- Throws:
CommonpException
- If can't be initiated.LomikelException
-
-
Method Detail
-
setEvaluatorFunctions
public void setEvaluatorFunctions(java.lang.String javaEF, java.lang.String bshEF) throws LomikelException
Set Java and BeanShell Evaluator Functions.- Parameters:
javaEF
- The Java Evaluatior Functions class name. May be null.bshEF
- The BeanShell Evaluatior Functions script name. May be null.- Throws:
CommonpException
- If can't be set.LomikelException
-
evalBoolean
public boolean evalBoolean(java.util.Map<java.lang.String,java.lang.String> values, java.lang.String formula) throws LomikelException
Evaluate boolean formula with supplied variables and values.- Parameters:
values
- The names and values of variables.formula
- The formula to be evaluated. It should use supplied variables, which will be filled with supplied values.- Throws:
LomikelException
- If formula cannot be evaluated with supplied variables.
-
qdistance0
public static double qdistance0(double v1, double v2, double v3, double v4)
-
evalDouble
public double evalDouble(java.util.Map<java.lang.String,java.lang.String> values, java.lang.String formula) throws LomikelException
Evaluate double formula with supplied variables and values.- Parameters:
values
- The names and values of variables.formula
- The formula to be evaluated. It should use supplied variables, which will be filled with supplied values.- Throws:
LomikelException
- If formula cannot be evaluated with supplied variables.
-
eval
public java.lang.String eval(java.util.Map<java.lang.String,java.lang.String> values, java.lang.String formula, java.lang.String type) throws LomikelException
Evaluate formula with supplied variables and values.- Parameters:
values
- The names and values of variables.formula
- The formula to be evaluated. It should use supplied variables, which will be filled with supplied values.type
- The formula result type.- Throws:
LomikelException
- If formula cannot be evaluated with supplied variables.
-
setVariable
public void setVariable(java.lang.String name)
Declare variable. Set to 0.- Parameters:
name
- The name of variables.
-
setVariable
public void setVariable(java.lang.String name, java.lang.String value)
Set variable.- Parameters:
name
- The name of variables.value
- The value of variables. Undefined types are considereddouble
, unknown types are taken asstring
.
-
setVariable
public void setVariable(java.lang.String name, double value)
TBD
-
setVariable
public void setVariable(java.lang.String name, java.lang.String[] values)
Set array variable.- Parameters:
name
- The name of variables.values
- The values of variables. Undefined types are considereddouble
, unknown types are taken asstring
.
-
setVariable
public void setVariable(java.lang.String name, double[] values)
TBD
-
variables
public java.lang.String[] variables()
Give the array of used variables.- Returns:
- The array of used variables.
-
hasVariable
public boolean hasVariable(java.lang.String var)
Shows whether a variable exists.- Parameters:
var
- The name of a variable.- Returns:
- Whether that variable exists.
-
setVariables
public void setVariables(java.lang.String formula)
Add variables to the list of used variables. Only add variables available inSchema
.- Parameters:
formula
- The formula to be used for list of used variables.
-
forceVariables
public void forceVariables(java.lang.String variables)
Add variables to the list of used variables. Add variables even if they are not available inSchema
.- Parameters:
formula
- The formula to be used for list of used variables.
-
varName
protected java.lang.String varName(java.lang.String fullName)
Give variable name from the database name.- Parameters:
fullName
- The fill name of the database column.- Returns:
- The schema variable name.
-
-