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


Java JEP类代码示例

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


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

示例1: replaceVariableInExpression

import org.nfunk.jep.JEP; //导入依赖的package包/类
private Expression replaceVariableInExpression(Expression oldExpression, Map<Integer, SetAlias> variableRenamings) {
    if (logger.isDebugEnabled()) logger.debug("Replacing paths in expression: " + oldExpression);
    Expression expression = oldExpression.clone();
    JEP jepExpression = expression.getJepExpression();
    SymbolTable symbolTable = jepExpression.getSymbolTable();
    for (Variable variable : symbolTable.getVariables()) {
        VariablePathExpression oldDescription = (VariablePathExpression) variable.getDescription();
        SetAlias newVariable = variableRenamings.get(oldDescription.getStartingVariable().getId());
        if (newVariable != null) {
            VariablePathExpression newDescription = new VariablePathExpression(oldDescription, newVariable);
            variable.setDescription(newDescription);
            variable.setOriginalDescription(newDescription.getAbsolutePath());
        }
    }
    if (logger.isDebugEnabled()) logger.debug("Resulting expression: " + expression);
    return expression;
}
 
开发者ID:dbunibas,项目名称:spicy,代码行数:18,代码来源:RenameSetAliasesUtility.java

示例2: checkSelectionCondition

import org.nfunk.jep.JEP; //导入依赖的package包/类
public void checkSelectionCondition(List<PathExpression> setPaths, Expression condition, INode root) throws ExpressionSyntaxException {
    if (condition == null) {
        throw new ExpressionSyntaxException("Transformation function cannot be null. Set path: " + setPaths);
    }
    StringBuilder errorMessage = new StringBuilder();
    JEP jepExpression = condition.getJepExpression();
    SymbolTable symbolTable = jepExpression.getSymbolTable();
    for (Variable variable : symbolTable.getVariables()) {
        String variableName = variable.getName();
        PathExpression variablePath = searchPathInSet(setPaths, variableName, root);
        if (variablePath == null) {
            errorMessage.append("Unable to find path for variable ").append(variableName).append("\n");
        } else {
            variable.setDescription(variablePath);
            variable.setOriginalDescription(variablePath);
        }
    }
    if (errorMessage.length() != 0) {
        throw new ExpressionSyntaxException(errorMessage.toString());
    }
}
 
开发者ID:dbunibas,项目名称:spicy,代码行数:22,代码来源:CheckExpressions.java

示例3: checkExpression

import org.nfunk.jep.JEP; //导入依赖的package包/类
public void checkExpression(List<PathExpression> sourcePaths, Expression expression) throws ExpressionSyntaxException {
    if (expression == null) {
        throw new ExpressionSyntaxException("Transformation function cannot be null. Source paths: " + sourcePaths);
    }
    StringBuilder errorMessage = new StringBuilder();
    JEP jepExpression = expression.getJepExpression();
    SymbolTable symbolTable = jepExpression.getSymbolTable();
    for (Variable variable : symbolTable.getVariables()) {
        String variableName = variable.getName();
        PathExpression variablePath = searchPath(sourcePaths, variableName);
        if (variablePath == null) {
            errorMessage.append("Unable to find path for variable ").append(variableName).append("\n");
        } else {
            variable.setDescription(variablePath);
            variable.setOriginalDescription(variablePath);
        }
    }
    if (errorMessage.length() != 0) {
        throw new ExpressionSyntaxException(errorMessage.toString());
    }
}
 
开发者ID:dbunibas,项目名称:spicy,代码行数:22,代码来源:CheckExpressions.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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;
}
 
开发者ID:jview,项目名称:jtools,代码行数:23,代码来源:Formula.java

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: addFunctions

import org.nfunk.jep.JEP; //导入依赖的package包/类
public static void addFunctions( JEP parser )
{        
    for ( Entry<String, PostfixMathCommandI> e : ALL_FUNCTIONS.entrySet() )
    {
        String fname = e.getKey();
        PostfixMathCommandI cmd = e.getValue();
        parser.addFunction( fname, cmd );
    }
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:10,代码来源:CustomFunctions.java

示例15: expressionIsTrue

import org.nfunk.jep.JEP; //导入依赖的package包/类
/**
 * Evaluates whether an expression is true or false.
 *
 * @param expression the expression to evaluate.
 * @return True if the expression is true, false otherwise.
 */
public static boolean expressionIsTrue( String expression )
{
    final JEP parser = getJep();
    parser.parseExpression( expression );

    return isEqual( parser.getValue(), 1.0 );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:14,代码来源:MathUtils.java


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