类 MathExpParser
java.lang.Object
com.sh.compile.express.MathExpParser
Description:
Title:首亨软件 - TSS/CRM等
- 从以下版本开始:
- 2014年12月11日
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidaddFunction(String functionName, Object function) voidAdds the constants pi and e to the parser.voidAdds the standard functions to the parser.addVariable(String name, double value) Adds a new variable to the parser, or updates the value of an existing variable.voidaddVariableCallback(MathExpVariable_I mevCallback) Reports information on the error in the expressiondoublegetValue()doublegetValue(DoubleStack evalStack) getVarNode(String var) booleanhasError()Reports whether there is an error in the expressionvoidInitializes the function tablevoidInitializes the symbol tablevoidparseExpression(String expression_in) Parses the expressionvoidsetVarNode(String var, ASTVarNode node)
-
构造器详细资料
-
MathExpParser
public MathExpParser()
-
-
方法详细资料
-
addVariableCallback
-
initSymTab
public void initSymTab()Initializes the symbol table -
initFunTab
public void initFunTab()Initializes the function table -
addStandardFunctions
public void addStandardFunctions()Adds the standard functions to the parser. If this function is not called before parsing an expression, functions such as sin() or cos() would produce an "Unrecognized function..." error. In most cases, this method should be called immediately after the JEP object is created. -
addStandardConstants
public void addStandardConstants()Adds the constants pi and e to the parser. As addStandardFunctions(), this method should be called immediatly after the JEP object is created. -
addFunction
-
addVariable
Adds a new variable to the parser, or updates the value of an existing variable. This must be done before parsing an expression so the parser is aware that the new variable may be contained in the expression.- 参数:
name- Name of the variable to be addedvalue- Initial value or new value for the variable- 返回:
- Double object of the variable
-
getVarNode
-
setVarNode
-
parseExpression
Parses the expression- 参数:
expression_in- The input expression string
-
getValue
- 抛出:
ParseException
-
getTopNode
-
getValue
- 抛出:
ParseException
-
hasError
public boolean hasError()Reports whether there is an error in the expression- 返回:
- Returns true if the expression has an error
-
getErrorInfo
Reports information on the error in the expression- 返回:
- Returns a string containing information on the error; null if no error has occured
-