本文整理汇总了Java中org.nfunk.jep.Variable类的典型用法代码示例。如果您正苦于以下问题:Java Variable类的具体用法?Java Variable怎么用?Java Variable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Variable类属于org.nfunk.jep包,在下文中一共展示了Variable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: set
import org.nfunk.jep.Variable; //导入依赖的package包/类
public void set(EvaluatorI pv, Node node, Object value) throws ParseException {
Node lhsNode = node.jjtGetChild(0);
if (!(lhsNode instanceof ASTVarNode))
throw new ParseException("Ele: lhs must be a variable");
ASTVarNode vn = (ASTVarNode) lhsNode;
Variable var = vn.getVar();
Object rhs = pv.eval(node.jjtGetChild(1));
int index = -1;
if (rhs instanceof Number) {
index = ((Number) rhs).intValue() - 1;
} else if (rhs instanceof Vector) {
Vector vec = (Vector) rhs;
if (vec.size() != 1)
throw new ParseException("Ele: only single dimension arrays supported in JEP");
index = ((Number) vec.firstElement()).intValue() - 1;
} else
throw new ParseException("Ele: rhs must be a number");
Object oldVarVal = var.getValue();
if (!(oldVarVal instanceof Vector))
throw new ParseException("Ele: the value of the variable must be a Vector");
Vector newVarVal = (Vector) ((Vector) oldVarVal).clone();
newVarVal.set(index, value);
var.setValue(newVarVal);
}
开发者ID:dynamo2,项目名称:tianma,代码行数:26,代码来源:Ele.java
示例2: invertComparison
import org.nfunk.jep.Variable; //导入依赖的package包/类
private void invertComparison(ComparisonAtom comparison) {
if (logger.isInfoEnabled()) logger.info("Inverting comparison " + comparison.toString());
String invertedOperator = DependencyUtility.invertOperator(comparison.getOperator());
StringBuilder stringExpression = new StringBuilder();
stringExpression.append(comparison.getLeftArgument());
stringExpression.append(invertedOperator);
stringExpression.append(comparison.getRightArgument());
Expression newExpression = new Expression(stringExpression.toString());
SymbolTable originalSymbolTable = comparison.getExpression().getJepExpression().getSymbolTable();
for (Variable variable : originalSymbolTable.getVariables()) {
newExpression.setVariableDescription(variable.getName(), variable.getDescription());
}
comparison.setOperator(invertedOperator);
comparison.setExpression(newExpression);
if (logger.isInfoEnabled()) logger.info("Inverted comparison " + comparison.toString());
}
开发者ID:dbunibas,项目名称:BART,代码行数:17,代码来源:GenerateVioGenQueries.java
示例3: replaceVariableInExpression
import org.nfunk.jep.Variable; //导入依赖的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
示例4: checkSelectionCondition
import org.nfunk.jep.Variable; //导入依赖的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
示例5: checkExpression
import org.nfunk.jep.Variable; //导入依赖的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
示例6: replaceVariablesInExpression
import org.nfunk.jep.Variable; //导入依赖的package包/类
private List<PathExpression> replaceVariablesInExpression(Expression expression, ParserTGD parserTgd) {
if (logger.isDebugEnabled()) logger.debug("Replacing paths in expression: " + expression);
List<PathExpression> pathList = new ArrayList<PathExpression>();
JEP jepExpression = expression.getJepExpression();
SymbolTable symbolTable = jepExpression.getSymbolTable();
for (Variable variable : symbolTable.getVariables()) {
String formulaVariable = (String) variable.getDescription();
PathExpression variablePath = findVariablePath(formulaVariable, parserTgd);
pathList.add(variablePath);
variable.setDescription(variablePath);
variable.setOriginalDescription(variablePath);
}
if (logger.isDebugEnabled()) logger.debug("Resulting expression: " + expression);
return pathList;
}
开发者ID:dbunibas,项目名称:spicy,代码行数:16,代码来源:ParseMappingTask.java
示例7: generateConditionForPath
import org.nfunk.jep.Variable; //导入依赖的package包/类
private VariableSelectionCondition generateConditionForPath(VariablePathExpression pathInCombination, String functionName) throws ExpressionSyntaxException {
// VariablePathExpression setPath = pathInCombination.getStartingVariable().getBindingPathExpression();
// Expression condition = new Expression(functionName + "(" + pathInCombination + ")");
// VariableSelectionCondition conditionForPath = new VariableSelectionCondition(setPath, condition);
Expression condition = new Expression(functionName + "(" + pathInCombination + ")");
VariableSelectionCondition conditionForPath = new VariableSelectionCondition(condition);
JEP jepExpression = condition.getJepExpression();
SymbolTable symbolTable = jepExpression.getSymbolTable();
Variable variable = symbolTable.getVariables().get(0);
variable.setDescription(pathInCombination);
variable.setOriginalDescription(pathInCombination.getAbsolutePath());
return conditionForPath;
}
开发者ID:dbunibas,项目名称:spicy,代码行数:14,代码来源:RewriteTgdsToHandleSourceNulls.java
示例8: setVariableDescriptions
import org.nfunk.jep.Variable; //导入依赖的package包/类
public boolean setVariableDescriptions(Expression expression, List<List<FormulaVariable>> variables) {
JEP jepExpression = expression.getJepExpression();
SymbolTable symbolTable = jepExpression.getSymbolTable();
List<FormulaVariable> formulaVariables = new ArrayList<FormulaVariable>();
for (Variable variable : symbolTable.getVariables()) {
// VariablePathExpression variablePath = (VariablePathExpression) variable.getDescription();
String pathString = variable.getDescription().toString();
FormulaVariable formulaVariable = findVariableForString(pathString, variables);
variable.setDescription(formulaVariable);
if (!formulaVariables.contains(formulaVariable)) {
formulaVariables.add(formulaVariable);
}
}
return formulaVariables.size() > 1;
}
开发者ID:dbunibas,项目名称:spicy,代码行数:16,代码来源:TGDToLogicalStringUtility.java
示例9: getAttributePaths
import org.nfunk.jep.Variable; //导入依赖的package包/类
public List<VariablePathExpression> getAttributePaths() {
List<VariablePathExpression> attributePaths = new ArrayList<VariablePathExpression>();
SymbolTable symbolTable = jepExpression.getSymbolTable();
for (Variable jepVariable : symbolTable.getVariables()) {
if (!attributePaths.contains(jepVariable.getDescription())) {
attributePaths.add((VariablePathExpression) jepVariable.getDescription());
}
}
return attributePaths;
}
开发者ID:dbunibas,项目名称:spicy,代码行数:11,代码来源:Expression.java
示例10: containsAllVariables
import org.nfunk.jep.Variable; //导入依赖的package包/类
private boolean containsAllVariables(SimpleConjunctiveQuery view, Expression filter, INode root) {
JEP jepExpression = filter.getJepExpression();
SymbolTable symbolTable = jepExpression.getSymbolTable();
for (org.nfunk.jep.Variable jepVariable : symbolTable.getVariables()) {
String variableName = jepVariable.getName();
PathExpression attributePath = searchPathInView(view, variableName, root);
if (attributePath == null) {
return false;
} else {
jepVariable.setDescription(attributePath);
jepVariable.setOriginalDescription(attributePath);
}
}
return true;
}
开发者ID:dbunibas,项目名称:spicy,代码行数:16,代码来源:CheckExpressions.java
示例11: findAliasesInVariableExpression
import org.nfunk.jep.Variable; //导入依赖的package包/类
public List<SetAlias> findAliasesInVariableExpression(Expression expression) {
List<SetAlias> result = new ArrayList<SetAlias>();
JEP jepExpression = expression.getJepExpression();
SymbolTable symbolTable = jepExpression.getSymbolTable();
for (Variable variable : symbolTable.getVariables()) {
VariablePathExpression variablePath = (VariablePathExpression) variable.getDescription();
SetAlias setVariable = variablePath.getStartingVariable();
if (!result.contains(setVariable)) {
result.add(setVariable);
}
}
return result;
}
开发者ID:dbunibas,项目名称:spicy,代码行数:14,代码来源:ContextualizePaths.java
示例12: replacePathsInExpression
import org.nfunk.jep.Variable; //导入依赖的package包/类
private void replacePathsInExpression(Expression expression, IDataSourceProxy dataSource) {
if (logger.isDebugEnabled()) logger.debug("Replacing paths in expression: " + expression);
JEP jepExpression = expression.getJepExpression();
SymbolTable symbolTable = jepExpression.getSymbolTable();
for (Variable variable : symbolTable.getVariables()) {
PathExpression variableAbsolutePath = (PathExpression) variable.getDescription();
VariablePathExpression variableRelativePath = generateRelativePath(variableAbsolutePath, dataSource);
variable.setDescription(variableRelativePath);
variable.setOriginalDescription(variableAbsolutePath);
}
if (logger.isDebugEnabled()) logger.debug("Resulting expression: " + expression);
}
开发者ID:dbunibas,项目名称:spicy,代码行数:13,代码来源:ContextualizePaths.java
示例13: set
import org.nfunk.jep.Variable; //导入依赖的package包/类
public void set(EvaluatorI pv, Node node, Object value)
throws ParseException {
Node lhsNode = node.jjtGetChild(0);
if(!(lhsNode instanceof ASTVarNode))
throw new ParseException("Ele: lhs must be a variable");
ASTVarNode vn = (ASTVarNode) lhsNode;
Variable var = pv.getSymbolTable().getVar(vn.getVarName());
Object rhs = pv.eval(node.jjtGetChild(1));
int index=-1;
if(rhs instanceof Number)
{
index=((Number) rhs).intValue()-1;
}
else if(rhs instanceof Vector)
{
Vector vec = (Vector) rhs;
if(vec.size()!=1) throw new ParseException("Ele: only single dimension arrays supported in JEP");
index = ((Number) vec.firstElement()).intValue()-1;
}
else throw new ParseException("Ele: rhs must be a number");
Object oldVarVal = var.getValue();
if(!(oldVarVal instanceof Vector))
throw new ParseException("Ele: the value of the variable must be a Vector");
Vector newVarVal = (Vector) ((Vector) oldVarVal).clone();
newVarVal.set(index,value);
var.setValue(newVarVal);
}
开发者ID:dbunibas,项目名称:spicy,代码行数:29,代码来源:Ele.java
示例14: testClone1
import org.nfunk.jep.Variable; //导入依赖的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
示例15: testClone2
import org.nfunk.jep.Variable; //导入依赖的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
示例16: test4
import org.nfunk.jep.Variable; //导入依赖的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
示例17: testClonazione1
import org.nfunk.jep.Variable; //导入依赖的package包/类
public void testClonazione1() {
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:donatellosantoro,项目名称:Llunatic,代码行数:38,代码来源:TestEspressioni.java
示例18: testClonazione2
import org.nfunk.jep.Variable; //导入依赖的package包/类
public void testClonazione2() {
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:donatellosantoro,项目名称:Llunatic,代码行数:37,代码来源:TestEspressioni.java
示例19: set
import org.nfunk.jep.Variable; //导入依赖的package包/类
public void set(EvaluatorI pv, Node node, Object value)
throws ParseException {
Node lhsNode = node.jjtGetChild(0);
if(!(lhsNode instanceof ASTVarNode))
throw new ParseException("Ele: lhs must be a variable");
ASTVarNode vn = (ASTVarNode) lhsNode;
Variable var = vn.getVar();
Object rhs = pv.eval(node.jjtGetChild(1));
int index=-1;
if(rhs instanceof Number)
{
index=((Number) rhs).intValue()-1;
}
else if(rhs instanceof Vector)
{
Vector vec = (Vector) rhs;
if(vec.size()!=1) throw new ParseException("Ele: only single dimension arrays supported in JEP");
index = ((Number) vec.firstElement()).intValue()-1;
}
else throw new ParseException("Ele: rhs must be a number");
Object oldVarVal = var.getValue();
if(!(oldVarVal instanceof Vector))
throw new ParseException("Ele: the value of the variable must be a Vector");
Vector newVarVal = (Vector) ((Vector) oldVarVal).clone();
newVarVal.set(index,value);
var.setValue(newVarVal);
}
开发者ID:maths,项目名称:dragmath,代码行数:29,代码来源:Ele.java
示例20: createVariable
import org.nfunk.jep.Variable; //导入依赖的package包/类
/** Create a variable with a given value. */
public Variable createVariable(String name, Object value) {
return new MatrixVariable(name, value);
}
开发者ID:dynamo2,项目名称:tianma,代码行数:5,代码来源:MatrixVariableFactory.java
注:本文中的org.nfunk.jep.Variable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论