T - type of real cart item.public abstract class EvalHelper<T> extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected static java.util.regex.Pattern |
JS_NAME_LOCATOR |
protected static java.util.regex.Pattern |
JS_NAME_VALIDATOR |
| Constructor and Description |
|---|
EvalHelper() |
| Modifier and Type | Method and Description |
|---|---|
EvalHelper<T> |
bindVaribles(IRule<T> rule) |
EvalHelper<T> |
bindVaribles(IRule<T> rule,
SingleItem<T> item)
Bind rule and item into evaluation context.
|
abstract EvalHelper<T> |
bindVarValue(java.lang.String variable,
java.lang.Object value)
Bind variable with value into context.
|
abstract <R> R |
eval(java.lang.String formula)
Evaluate formula as numeric or boolean.
|
abstract java.lang.String |
getPreviousRulePrefix()
A prefix string add on comman variable to represent a previous rule's
variable.
|
abstract java.lang.String |
getVarContainsCount()
Variable name of which represent the number of items that could
applicable to this rule.
|
abstract java.lang.String |
getVarRegularPrice()
Variable name of regular price.
|
abstract java.lang.String |
getVarSalePrice()
Variable name of sale price.
|
abstract java.lang.String |
getVarSerialNum()
Variable name of which represent the sequence of the same applicable
items.
|
abstract java.lang.String |
getVarSumOfContainsRegularPrice()
Variable name of which represent the summary regular price of applicable
items.
|
abstract java.lang.String |
getVarSumOfContainsSalePrice()
Variable name of which represent the summary sale price of applicable
items.
|
abstract java.lang.String |
getVarSumOfSerialRegularPrice()
Variable name of which represent the summary regular price of the same
applicable items.
|
abstract java.lang.String |
getVarSumOfSerialSalePrice()
Variable name of which represent the summary sale price of the same
applicable items.
|
protected abstract void |
purgeBind()
Clear all binding variable in context.
|
void |
validateJSVariable()
Check all variables name are qualified javascript name.
|
static java.lang.String |
validJSVarName(java.lang.String javaScriptVVariableName)
Check a variable name is a qualified javascript name.
|
protected static final java.util.regex.Pattern JS_NAME_LOCATOR
protected static final java.util.regex.Pattern JS_NAME_VALIDATOR
public EvalHelper()
public EvalHelper<T> bindVaribles(IRule<T> rule)
public static java.lang.String validJSVarName(java.lang.String javaScriptVVariableName) throws javax.script.ScriptException
javaScriptVVariableName - the vaiable namejavax.script.ScriptException - Exception prone when a variable name is not
qualified.public EvalHelper<T> bindVaribles(IRule<T> rule, SingleItem<T> item)
rule - item - public void validateJSVariable() throws javax.script.ScriptException
javax.script.ScriptException - Exception prone when any one variable name is not
qualified.public abstract java.lang.String getPreviousRulePrefix()
public abstract java.lang.String getVarSalePrice()
public abstract java.lang.String getVarRegularPrice()
public abstract java.lang.String getVarSerialNum()
public abstract java.lang.String getVarContainsCount()
public abstract java.lang.String getVarSumOfContainsRegularPrice()
public abstract java.lang.String getVarSumOfContainsSalePrice()
public abstract java.lang.String getVarSumOfSerialRegularPrice()
public abstract java.lang.String getVarSumOfSerialSalePrice()
public abstract EvalHelper<T> bindVarValue(java.lang.String variable, java.lang.Object value)
variable - value - protected abstract void purgeBind()
public abstract <R> R eval(java.lang.String formula) throws javax.script.ScriptException
R - return typeformula - javax.script.ScriptException - Exception prone when a formula is not qualified.Copyright © 2019. All rights reserved.