本文整理汇总了Java中org.nfunk.jep.JEP.hasError方法的典型用法代码示例。如果您正苦于以下问题:Java JEP.hasError方法的具体用法?Java JEP.hasError怎么用?Java JEP.hasError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.nfunk.jep.JEP
的用法示例。
在下文中一共展示了JEP.hasError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formulaParser
import org.nfunk.jep.JEP; //导入方法依赖的package包/类
/**
* 计算数学表达式
* @param value
* @return
*/
public static double formulaParser (String value){
double sum = 0;
JEP myParser = null;
if(myParser==null){
myParser = getJep();
}
try{
myParser.parseExpression(value);
boolean hasError = myParser.hasError();
sum = myParser.getValue();
}catch(Exception e){
e.printStackTrace();
}
return sum;
}
示例2: process
import org.nfunk.jep.JEP; //导入方法依赖的package包/类
@Override
public void process(RegisterData data, String funcArg) {
log.trace("Processing: "+funcArg);
JEP j = new JEP();
j.addStandardConstants();
j.addStandardFunctions();
j.addConstant("$", new Double(data.getFloat()));
j.parseExpression(funcArg);
if (j.hasError()) {
log.error((j.getErrorInfo()));
data.setNull();
} else {
Double value = j.getValue();
if (j.hasError()) {
log.error(j.getErrorInfo());
} else {
data.setDataFloat(value.floatValue());
log.trace("Evaluated to : "+value);
}
}
}
示例3: expressionHasErrors
import org.nfunk.jep.JEP; //导入方法依赖的package包/类
/**
* Investigates whether the expression is valid or has errors.
*
* @param expression The expression to validate.
* @return True if the expression has errors, false otherwise.
*/
public static boolean expressionHasErrors( String expression )
{
final JEP parser = getJep();
parser.parseExpression( expression );
return parser.hasError();
}
示例4: calculateExpression
import org.nfunk.jep.JEP; //导入方法依赖的package包/类
/**
* Calculate the expression.
*
* @param expression
* Expression string
* @return calculate result
* @throws IllegalArgumentException
*/
public static double calculateExpression(String expression) throws IllegalArgumentException {
JEP myParser = new JEP();
myParser.parseExpression(expression);
if (myParser.hasError()) {
throw new IllegalArgumentException();
}
return myParser.getValue();
}
示例5: expressionHasErrors
import org.nfunk.jep.JEP; //导入方法依赖的package包/类
/**
* Investigates whether the expression is valid or has errors.
*
* @param expression The expression to validate.
* @return True if the expression has errors, false otherwise.
*/
public static boolean expressionHasErrors( String expression )
{
final JEP parser = getJep();
parser.parseExpression( expression );
return parser.hasError();
}
示例6: Expression
import org.nfunk.jep.JEP; //导入方法依赖的package包/类
public Expression(String expression) throws ExpressionSyntaxException {
jepExpression = new JEP();
jepExpression.setAllowUndeclared(true);
jepExpression.addStandardConstants();
jepExpression.addStandardFunctions();
jepExpression.parseExpression(expression);
if (jepExpression.hasError()) {
throw new ExpressionSyntaxException(jepExpression.getErrorInfo());
}
if (logger.isDebugEnabled()) logger.debug("Created expression: " + jepExpression);
}
示例7: run
import org.nfunk.jep.JEP; //导入方法依赖的package包/类
/** The input loop */
public void run(String args[]) throws IOException {
String command="";
JEP j = new JEP();
j.addStandardConstants();
j.addStandardFunctions();
j.addComplex();
//j.setTraverse(true);
if (args.length>0) {
// evaluate the expression passed as arguments
String temp = args[0];
for (int i=1; i<args.length; i++) temp += " " + args[i];
j.parseExpression(temp);
if (j.hasError())
System.out.println(j.getErrorInfo());
else
System.out.println(j.getValueAsObject());
} else {
// no arguments - interactive mode
System.out.println("JEP - Enter q to quit");
System.out.print(prompt);
while ((command = getCommand()) != null) {
j.parseExpression(command);
if (j.hasError()) {
System.out.println(j.getErrorInfo());
} else {
// expression is OK, get the value
Object value = j.getValueAsObject();
// did error occur during evaluation?
if (j.hasError()) {
System.out.println(j.getErrorInfo());
} else {
System.out.println(value);
}
/*
System.out.println(
(LinearVisitor.isLinear(j.getTopNode())) ?
"Linear" : "Not Linear");
System.out.println(
(ConstantVisitor.isConstant(j.getTopNode())) ?
"Constant" : "Not Constant");
*/
}
System.out.print(prompt);
}
}
}