use of cbit.vcell.parser.ExpressionTerm in project vcell by virtualcell.
the class MathTestingUtilities method getInsideOutsideFunctions.
/**
* Insert the method's description here.
* Creation date: (1/23/2003 10:30:23 PM)
* @return cbit.vcell.parser.Expression
* @param analyticSubDomainExp cbit.vcell.parser.Expression
*/
public static Expression[] getInsideOutsideFunctions(Expression analyticSubDomainExp) throws ExpressionException, MappingException {
Expression analyticExp = new Expression(analyticSubDomainExp);
analyticExp.bindExpression(null);
analyticExp = analyticExp.flatten();
java.util.Stack<Expression> unparsedExpressionStack = new java.util.Stack<Expression>();
java.util.Vector<Expression> expList = new java.util.Vector<Expression>();
unparsedExpressionStack.push(analyticExp);
while (unparsedExpressionStack.size() > 0) {
Expression exp = unparsedExpressionStack.pop();
if (exp.isRelational()) {
ExpressionTerm expTerm = exp.extractTopLevelTerm();
if (expTerm.getOperator().equals("<") || expTerm.getOperator().equals("<=")) {
expList.add(new Expression(expTerm.getOperands()[0].infix() + "-" + expTerm.getOperands()[1].infix()));
} else if (expTerm.getOperator().equals(">") || expTerm.getOperator().equals(">=")) {
expList.add(new Expression(expTerm.getOperands()[1].infix() + "-" + expTerm.getOperands()[0].infix()));
} else {
throw new ExpressionException("relational expression '" + exp + "' is not an inequality");
}
} else if (exp.isLogical()) {
ExpressionTerm expTerm = exp.extractTopLevelTerm();
for (int i = 0; i < expTerm.getOperands().length; i++) {
unparsedExpressionStack.push(expTerm.getOperands()[i]);
}
} else {
throw new ExpressionException("expression '" + exp + "' is neither relational nor logical, bad analytic geometry");
}
}
return (Expression[]) BeanUtils.getArray(expList, Expression.class);
}
Aggregations