public Object apply(EvaluatorState state, List<Object> arguments) { if (arguments.size() < 1) throw new BadOperandCountException(arguments.size(), 1, 1); else { Class<?> operandClass = String.class; Object o0 = arguments.get(0); if (checkCompatibleOperand(o0, operandClass)) { o0 = convertCompatibleOperand(o0, operandClass); assert o0 instanceof String; String designator = (String) o0; return Boolean.valueOf(features.contains(designator)); } else throw new IncompatibleOperandException(o0, operandClass); } } }
public Object apply(EvaluatorState state, List<Object> arguments) { if (arguments.size() < 1) throw new BadOperandCountException(arguments.size(), 1, 1); else { Class<?> operandClass = String.class; Object o0 = arguments.get(0); if (checkCompatibleOperand(o0, operandClass)) { o0 = convertCompatibleOperand(o0, operandClass); assert o0 instanceof String; String name = (String) o0; if (parameters.containsKey(name)) return parameters.get(name); else throw new UnknownParameterException(name); } else throw new IncompatibleOperandException(o0, operandClass); } } }
public Object apply(EvaluatorState state, List<Object> arguments) { if (arguments.size() < 1) throw new BadOperandCountException(arguments.size(), 1, 1); else { Class<?> operandClass = String.class; Object o0 = arguments.get(0); if (checkCompatibleOperand(o0, operandClass)) { o0 = convertCompatibleOperand(o0, operandClass); assert o0 instanceof String; String query = (String) o0; try { MediaQuery mq = MediaQuery.valueOf(query); return mq.evaluate(parameters); } catch (MediaQuery.ParserException e) { throw new BuiltinFunctionException(e); } } else throw new IncompatibleOperandException(o0, operandClass); } } }
return evaluate(ee.getState(), e, operator, (Number) o0, (Number) convertCompatibleOperand(o1, operandClass)); } else { throw new IncompatibleOperandException(e, o1, operandClass); return evaluate(ee.getState(), e, operator, (String) o0, (String) convertCompatibleOperand(o1, operandClass)); } else { throw new IncompatibleOperandException(e, o1, operandClass); return evaluate(ee.getState(), e, operator, (Boolean) o0, (Boolean) convertCompatibleOperand(o1, operandClass)); } else { throw new IncompatibleOperandException(e, o1, operandClass);
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"); }
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"); }