@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { try { Boolean value = this.children[0].getValue(state, Boolean.class); if (value == null) { throw new SpelEvaluationException(SpelMessage.TYPE_CONVERSION_ERROR, "null", "boolean"); } return BooleanTypedValue.forValue(!value); } catch (SpelEvaluationException ex) { ex.setPosition(getChild(0).getStartPosition()); throw ex; } }
/** * Evaluate the condition and if true evaluate the first alternative, otherwise * evaluate the second alternative. * @param state the expression state * @throws EvaluationException if the condition does not evaluate correctly to * a boolean or there is a problem executing the chosen alternative */ @Override public TypedValue getValueInternal(ExpressionState state) throws EvaluationException { Boolean value = this.children[0].getValue(state, Boolean.class); if (value == null) { throw new SpelEvaluationException(getChild(0).getStartPosition(), SpelMessage.TYPE_CONVERSION_ERROR, "null", "boolean"); } TypedValue result = this.children[value ? 1 : 2].getValueInternal(state); computeExitTypeDescriptor(); return result; }
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { try { Boolean value = this.children[0].getValue(state, Boolean.class); if (value == null) { throw new SpelEvaluationException(SpelMessage.TYPE_CONVERSION_ERROR, "null", "boolean"); } return BooleanTypedValue.forValue(!value); } catch (SpelEvaluationException ex) { ex.setPosition(getChild(0).getStartPosition()); throw ex; } }
/** * Evaluate the condition and if true evaluate the first alternative, otherwise * evaluate the second alternative. * @param state the expression state * @throws EvaluationException if the condition does not evaluate correctly to * a boolean or there is a problem executing the chosen alternative */ @Override public TypedValue getValueInternal(ExpressionState state) throws EvaluationException { Boolean value = this.children[0].getValue(state, Boolean.class); if (value == null) { throw new SpelEvaluationException(getChild(0).getStartPosition(), SpelMessage.TYPE_CONVERSION_ERROR, "null", "boolean"); } TypedValue result = this.children[value ? 1 : 2].getValueInternal(state); computeExitTypeDescriptor(); return result; }
throw new SpelEvaluationException(getChild(0).getStartPosition(), SpelMessage.TYPE_NAME_EXPECTED_FOR_ARRAY_CONSTRUCTION, FormatHelper.formatClassNameForMessage(
throw new SpelEvaluationException(getChild(0).getStartPosition(), SpelMessage.TYPE_NAME_EXPECTED_FOR_ARRAY_CONSTRUCTION, FormatHelper.formatClassNameForMessage(
@Test public void positionalInformation() { SpelExpression expr = new SpelExpressionParser().parseRaw("true and true or false"); SpelNode rootAst = expr.getAST(); OpOr operatorOr = (OpOr) rootAst; OpAnd operatorAnd = (OpAnd) operatorOr.getLeftOperand(); SpelNode rightOrOperand = operatorOr.getRightOperand(); // check position for final 'false' assertEquals(17, rightOrOperand.getStartPosition()); assertEquals(22, rightOrOperand.getEndPosition()); // check position for first 'true' assertEquals(0, operatorAnd.getLeftOperand().getStartPosition()); assertEquals(4, operatorAnd.getLeftOperand().getEndPosition()); // check position for second 'true' assertEquals(9, operatorAnd.getRightOperand().getStartPosition()); assertEquals(13, operatorAnd.getRightOperand().getEndPosition()); // check position for OperatorAnd assertEquals(5, operatorAnd.getStartPosition()); assertEquals(8, operatorAnd.getEndPosition()); // check position for OperatorOr assertEquals(14, operatorOr.getStartPosition()); assertEquals(16, operatorOr.getEndPosition()); }
@Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { try { Boolean value = this.children[0].getValue(state, Boolean.class); if (value == null) { throw new SpelEvaluationException(SpelMessage.TYPE_CONVERSION_ERROR, "null", "boolean"); } return BooleanTypedValue.forValue(!value); } catch (SpelEvaluationException ex) { ex.setPosition(getChild(0).getStartPosition()); throw ex; } }
/** * Evaluate the condition and if true evaluate the first alternative, otherwise * evaluate the second alternative. * @param state the expression state * @throws EvaluationException if the condition does not evaluate correctly to * a boolean or there is a problem executing the chosen alternative */ @Override public TypedValue getValueInternal(ExpressionState state) throws EvaluationException { Boolean value = this.children[0].getValue(state, Boolean.class); if (value == null) { throw new SpelEvaluationException(getChild(0).getStartPosition(), SpelMessage.TYPE_CONVERSION_ERROR, "null", "boolean"); } TypedValue result = this.children[value ? 1 : 2].getValueInternal(state); computeExitTypeDescriptor(); return result; }
throw new SpelEvaluationException(getChild(0).getStartPosition(), SpelMessage.TYPE_NAME_EXPECTED_FOR_ARRAY_CONSTRUCTION, FormatHelper.formatClassNameForMessage(