当前位置: 首页>>代码示例>>Java>>正文


Java JEP.addStandardFunctions方法代码示例

本文整理汇总了Java中org.nfunk.jep.JEP.addStandardFunctions方法的典型用法代码示例。如果您正苦于以下问题:Java JEP.addStandardFunctions方法的具体用法?Java JEP.addStandardFunctions怎么用?Java JEP.addStandardFunctions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.nfunk.jep.JEP的用法示例。


在下文中一共展示了JEP.addStandardFunctions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testClone3

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
public void testClone3() {
    JEP jepExpression = new JEP();
    jepExpression.setAllowUndeclared(true);
    jepExpression.addStandardConstants();
    jepExpression.addStandardFunctions();

    jepExpression.parseExpression("append(a, b, c)");
    System.out.println("JEP: " + jepExpression);
    System.out.println(jepExpression.getTopNode().toLongString());
    jepExpression.setVarValue("a", "Uno");
    jepExpression.setVarValue("b", "Due");
    jepExpression.setVarValue("c", "Tre");
    System.out.println("Value: " + jepExpression.getValueAsObject());

    JEP clone = (JEP) jepExpression.clone();
    clone.setVarValue("a", "Dieci");
    clone.setVarValue("b", "Undici");
    clone.setVarValue("c", "Dodici");

    System.out.println("Value originale: " + jepExpression.getValueAsObject());
    System.out.println("Value clone: " + clone.getValueAsObject());

}
 
开发者ID:dbunibas,项目名称:spicy,代码行数:24,代码来源:TestExpressions.java

示例2: test6

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
public void test6() {
    JEP jepExpression = new JEP();
    jepExpression.setAllowUndeclared(true);
    jepExpression.addStandardConstants();
    jepExpression.addStandardFunctions();
    jepExpression.parseExpression("year > 1980");
    System.out.println("JEP: " + jepExpression);
    jepExpression.setVarValue("year", 1981);
    Object value1 = jepExpression.getValueAsObject();
    System.out.println("Value: " + value1);
    assertEquals(1.0, value1);
    jepExpression.setVarValue("year", 1971);
    Object value2 = jepExpression.getValueAsObject();
    System.out.println("Value: " + value2);
    assertEquals(0.0, value2);        
    jepExpression.setVarValue("year", "1971");
    System.out.println("Value: " + jepExpression.getValueAsObject());
}
 
开发者ID:dbunibas,项目名称:spicy,代码行数:19,代码来源:TestExpressions.java

示例3: getJep

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
/**
 * 初始化解析器
 * @return
 */
private static JEP getJep(){
	JEP myParser = new JEP();
	
	// Allow implicit multiplication
	myParser.setImplicitMul(true);

	// Load the standard functions
	myParser.addStandardFunctions();

	// Load the standard constants, and complex variables/functions
	myParser.addStandardConstants();
	myParser.addComplex();
	
	// Add and initialize x to 0
	myParser.addVariable("x",0);
	return myParser;
}
 
开发者ID:jview,项目名称:jtools,代码行数:22,代码来源:Formula.java

示例4: testClonazione3

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
public void testClonazione3() {
    JEP jepExpression = new JEP();
    jepExpression.setAllowUndeclared(true);
    jepExpression.addStandardConstants();
    jepExpression.addStandardFunctions();

    jepExpression.parseExpression("append(a, b, c)");
    System.out.println("JEP: " + jepExpression);
    System.out.println(jepExpression.getTopNode().toLongString());
    jepExpression.setVarValue("a", "Uno");
    jepExpression.setVarValue("b", "Due");
    jepExpression.setVarValue("c", "Tre");
    System.out.println("Value: " + jepExpression.getValueAsObject());

    JEP clone = (JEP) jepExpression.clone();
    clone.setVarValue("a", "Dieci");
    clone.setVarValue("b", "Undici");
    clone.setVarValue("c", "Dodici");

    System.out.println("Value originale: " + jepExpression.getValueAsObject());
    System.out.println("Value clone: " + clone.getValueAsObject());

}
 
开发者ID:donatellosantoro,项目名称:Llunatic,代码行数:24,代码来源:TestEspressioni.java

示例5: init

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
/**
 * The initialization function of the applet. It adds all the
 * components such as text fields and also creates the JEP object
 */
public void init() {
	// initialize value for x
	xValue = 10;

	// add the interface components
	addGUIComponents();
	
	// Set up the parser (more initialization in parseExpression()) 
	myParser = new JEP();
	myParser.initFunTab(); // clear the contents of the function table
	myParser.addStandardFunctions();
	myParser.setTraverse(true);

	
	// simulate changed options to initialize output
	optionsChanged();
}
 
开发者ID:Kailashrb,项目名称:Jep,代码行数:22,代码来源:Evaluator.java

示例6: initParser

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
/**
 * Initializes the parser
 */
private void initParser(String initialExpression) {
	// Init Parser
	myParser = new JEP();
	
	// Allow implicit multiplication
	myParser.setImplicitMul(true);

	// Load the standard functions
	myParser.addStandardFunctions();

	// Load the standard constants, and complex variables/functions
	myParser.addStandardConstants();
	myParser.addComplex();
	
	// Add and initialize x to 0
	myParser.addVariable("x",0);

	// Set the string to the initial value
	setExpressionString(initialExpression);
}
 
开发者ID:Kailashrb,项目名称:Jep,代码行数:24,代码来源:GraphCanvas.java

示例7: initParser

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
@Override
public void initParser(boolean useStandardConstants, Process process) {
	parser = new JEP();
	parser.addStandardFunctions();
	if (useStandardConstants)
		parser.addStandardConstants();

	addCustomFunctions();
	addCustomConstants();

	setAllowUndeclared(false);
	setImplicitMul(false);

	if (process != null) {
		parser.addFunction("param", new ParameterValue(process));
		parser.addFunction("macro", new MacroValue(process));
		parser.removeFunction("rand");
		parser.addFunction("rand", new Random(process));
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:21,代码来源:ExpressionParser.java

示例8: 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);
		}
	}
}
 
开发者ID:therealchalz,项目名称:softlogger,代码行数:25,代码来源:ExpressionParserDataFunction.java

示例9: getValue

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
@Override
public double getValue() throws CalcExeption {
	// If no formula is set, throw an exception.
	if(formula == null){
		throw new CalcFormulaNotSetException();
	}
	
	// JEP parser instance
	JEP parser = new JEP();
	parser.addStandardConstants();
	parser.addStandardFunctions();
	// Initiate parameters
	Iterator<String> params = parameters.keySet().iterator();
	while(params.hasNext()){
		String key = params.next();
		parser.addVariable(key, parameters.get(key).getValue());
	}
	
	// Set the expression to parse
	parser.parseExpression(formula);
	parser.getSymbolTable().toString();
	
	// Get the result
	double result = parser.getValue();
	if(Double.isNaN(result)){
		throw new CalcParameterNotSetException();
	}
	return result;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:30,代码来源:CalcFormula.java

示例10: getJep

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
/**
 * Returns an JEP parser instance.
 */
private static JEP getJep()
{
    final JEP parser = new JEP();
    parser.addStandardFunctions();
    CustomFunctions.addFunctions( parser );
    return parser;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:11,代码来源:MathUtils.java

示例11: getJep

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
/**
 * Returns an JEP parser instance.
 */
private static JEP getJep()
{
    final JEP parser = new JEP();
    parser.addStandardFunctions();
    return parser;
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:10,代码来源:MathUtils.java

示例12: 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);
}
 
开发者ID:dbunibas,项目名称:spicy,代码行数:12,代码来源:Expression.java

示例13: testClone1

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
public void testClone1() {
    JEP jepExpression = new JEP();
    jepExpression.setAllowUndeclared(true);
    jepExpression.addStandardConstants();
    jepExpression.addStandardFunctions();

    jepExpression.parseExpression("(a + 1) * (b - 3)");
    System.out.println("JEP: " + jepExpression);
    System.out.println(jepExpression.getTopNode().toLongString());
    System.out.println("Errori: " + jepExpression.getErrorInfo());
    Variable a = jepExpression.getVar("a");
    Variable b = jepExpression.getVar("b");
    jepExpression.setVarValue("a", 1);
    jepExpression.setVarValue("b", 2);
    System.out.println("Value: " + jepExpression.getValueAsObject());

    JEP clone = (JEP) jepExpression.clone();
    Variable aClone = clone.getVar("a");
    aClone.setDescription("a.a");
    Variable bClone = clone.getVar("b");
    bClone.setDescription("b.b");
    System.out.println(clone.getTopNode().toLongString());
    clone.setVarValue("a", 10);
    clone.setVarValue("b", 30);

    System.out.println("Value originale: " + jepExpression.getValueAsObject());
    System.out.println("Value clone: " + clone.getValueAsObject());

    System.out.println("Variable a originale: " + a.toString() + " - " + a.hashCode());
    System.out.println("Variable a clone: " + aClone.toString() + " - " + aClone.hashCode());

    System.out.println("Variable b originale: " + b.toString() + " - " + b.hashCode());
    System.out.println("Variable b clone: " + bClone.toString() + " - " + bClone.hashCode());

    System.out.println("Symbol table: " + jepExpression.getSymbolTable() + " - " + jepExpression.getSymbolTable().hashCode());
    System.out.println("Symbol table clone: " + clone.getSymbolTable() + " - " + clone.getSymbolTable().hashCode());
}
 
开发者ID:dbunibas,项目名称:spicy,代码行数:38,代码来源:TestExpressions.java

示例14: testClone2

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
public void testClone2() {
    JEP jepExpression = new JEP();
    jepExpression.setAllowUndeclared(true);
    jepExpression.addStandardConstants();
    jepExpression.addStandardFunctions();

    jepExpression.parseExpression("log(a) + sin(b)");
    System.out.println("JEP: " + jepExpression);
    System.out.println(jepExpression.getTopNode().toLongString());
    Variable a = jepExpression.getVar("a");
    Variable b = jepExpression.getVar("b");
    jepExpression.setVarValue("a", 1);
    jepExpression.setVarValue("b", 2);
    System.out.println("Value: " + jepExpression.getValueAsObject());

    JEP clone = (JEP) jepExpression.clone();
    Variable aClone = clone.getVar("a");
    aClone.setDescription("a.a");
    Variable bClone = clone.getVar("b");
    bClone.setDescription("b.b");
    System.out.println(clone.getTopNode().toLongString());
    clone.setVarValue("a", 10);
    clone.setVarValue("b", 30);

    System.out.println("Value originale: " + jepExpression.getValueAsObject());
    System.out.println("Value clone: " + clone.getValueAsObject());

    System.out.println("Variable a originale: " + a.toString() + " - " + a.hashCode());
    System.out.println("Variable a clone: " + aClone.toString() + " - " + aClone.hashCode());

    System.out.println("Variable b originale: " + b.toString() + " - " + b.hashCode());
    System.out.println("Variable b clone: " + bClone.toString() + " - " + bClone.hashCode());

    System.out.println("Symbol table: " + jepExpression.getSymbolTable() + " - " + jepExpression.getSymbolTable().hashCode());
    System.out.println("Symbol table clone: " + clone.getSymbolTable() + " - " + clone.getSymbolTable().hashCode());
}
 
开发者ID:dbunibas,项目名称:spicy,代码行数:37,代码来源:TestExpressions.java

示例15: test4

import org.nfunk.jep.JEP; //导入方法依赖的package包/类
public void test4() {
        JEP jepExpression = new JEP();
        jepExpression.setAllowUndeclared(true);
        jepExpression.addStandardConstants();
        jepExpression.addStandardFunctions();
//        jepExpression.parseExpression("((paolo + marco + giovanni) * log(franco) ) == 1.0");
        jepExpression.parseExpression("( ( (paolo + marco + giovanni) * log(franco) ) == 1.0 ) && (!luigi)");
        System.out.println("JEP: " + jepExpression);

        Variable a = jepExpression.getVar("paolo");
        a.setDescription("v2.paolo");
        System.out.println("JEP: " + jepExpression);
    }
 
开发者ID:dbunibas,项目名称:spicy,代码行数:14,代码来源:TestExpressions.java


注:本文中的org.nfunk.jep.JEP.addStandardFunctions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。