public Object evaluate(ExpressionEvaluator ee, Expression e) { if (checkOperator(e)) { final int minCount = 1; final int maxCount = -1; if (checkOperandCount(e, minCount, maxCount)) { Object o0 = ee.evaluate(e.getOperand(0)); if (o0 instanceof EvaluatorFunction) { EvaluatorFunction f = (EvaluatorFunction) o0; Object o1 = e.getOperand(1); if (o1 instanceof Expression) { Expression eArguments = (Expression) o1; if (eArguments.getOperator() == Operator.GROUP) { List<Object> arguments = new java.util.ArrayList<Object>(); for (Object operand : eArguments.getOperands()) { arguments.add(ee.evaluate(operand)); } return f.apply(ee.getState(), arguments); } else throw new IllegalStateException(); } else throw new IllegalStateException(); } else throw new IncompatibleOperandException(e, o0, EvaluatorFunction.class); } else throw new BadOperandCountException(e, minCount, maxCount); } else throw new BadOperatorException(e, "apply"); }
throw new BadOperandCountException(e, minCount, maxCount); } else throw new BadOperatorException(e, "binary arithmetic");
public Object evaluate(ExpressionEvaluator ee, Expression e) { if (checkOperator(e)) { final int minCount = 2; final int maxCount = 2; if (checkOperandCount(e, minCount, maxCount)) { Class<?> operandClass = Boolean.class; Object o0 = ee.evaluate(e.getOperand(0)); if (!checkCompatibleOperand(o0, operandClass)) throw new IncompatibleOperandException(e, o0, operandClass); else o0 = convertCompatibleOperand(o0, operandClass); Object o1 = ee.evaluate(e.getOperand(1)); if (!checkCompatibleOperand(o1, operandClass)) throw new IncompatibleOperandException(e, o1, operandClass); else o1 = convertCompatibleOperand(o1, operandClass); return evaluate(ee.getState(), e.getOperator(), o0, o1); } else throw new BadOperandCountException(e, minCount, maxCount); } else throw new BadOperatorException(e, "binary logic"); }
public Object evaluate(ExpressionEvaluator ee, Expression e) { if (checkOperator(e)) { final int minCount = 2; final int maxCount = 2; if (checkOperandCount(e, minCount, maxCount)) { Class<?> operandClass = Number.class; Object o0 = ee.evaluate(e.getOperand(0)); if (!checkCompatibleOperand(o0, operandClass)) throw new IncompatibleOperandException(e, o0, operandClass); else o0 = convertCompatibleOperand(o0, operandClass); Object o1 = ee.evaluate(e.getOperand(1)); if (!checkCompatibleOperand(o1, operandClass)) throw new IncompatibleOperandException(e, o1, operandClass); else o1 = convertCompatibleOperand(o1, operandClass); return evaluate(ee.getState(), e.getOperator(), o0, o1); } else throw new BadOperandCountException(e, minCount, maxCount); } else throw new BadOperatorException(e, "binary arithmetic"); }
public Object evaluate(ExpressionEvaluator ee, Expression e) { if (checkOperator(e)) { final int minCount = 1; final int maxCount = 1; if (checkOperandCount(e, minCount, maxCount)) { Class<?> operandClass = Boolean.class; Object o0 = ee.evaluate(e.getOperand(0)); if (!checkCompatibleOperand(o0, operandClass)) throw new IncompatibleOperandException(e, o0, operandClass); else o0 = convertCompatibleOperand(o0, operandClass); return evaluate(ee.getState(), e.getOperator(), o0); } else throw new BadOperandCountException(e, minCount, maxCount); } else throw new BadOperatorException(e, "unary logic"); }
public Object evaluate(ExpressionEvaluator ee, Expression e) { if (checkOperator(e)) { final int minCount = 1; final int maxCount = 1; if (checkOperandCount(e, minCount, maxCount)) { Class<?> operandClass = Number.class; Object o0 = ee.evaluate(e.getOperand(0)); if (!checkCompatibleOperand(o0, operandClass)) throw new IncompatibleOperandException(e, o0, operandClass); else o0 = convertCompatibleOperand(o0, operandClass); return evaluate(ee.getState(), e.getOperator(), o0); } else throw new BadOperandCountException(e, minCount, maxCount); } else throw new BadOperatorException(e, "unary arithmetic"); }
public Object evaluate(ExpressionEvaluator ee, Expression e) { if (checkOperator(e)) { final int count = 1; if (checkOperandCount(e, count)) { Object o0 = e.getOperand(0); if (!(o0 instanceof Token)) throw new IncompatibleOperandException(e, o0, Token.class); else return evaluate(ee.getState(), e.getOperator(), o0); } else throw new BadOperandCountException(e, count, count); } else throw new BadOperatorException(e, "literal"); }
public Object evaluate(ExpressionEvaluator ee, Expression e) { if (checkOperator(e)) { final int count = 1; if (checkOperandCount(e, count)) { return ee.evaluate(e.getOperand(0)); } else throw new BadOperandCountException(e, count, count); } else throw new BadOperatorException(e, "group"); }