@Override public void setValue(ExpressionState expressionState, @Nullable Object newValue) throws EvaluationException { throw new SpelEvaluationException(getStartPosition(), SpelMessage.SETVALUE_NOT_SUPPORTED, getClass()); }
@Override public void setValue(@Nullable Object newValue) { throw new SpelEvaluationException( this.node.getStartPosition(), SpelMessage.NOT_ASSIGNABLE, this.node.toStringAST()); }
protected ValueRef getValueRef(ExpressionState state) throws EvaluationException { throw new SpelEvaluationException(getStartPosition(), SpelMessage.NOT_ASSIGNABLE, toStringAST()); }
@Nullable private SpelNodeImpl eatPrimaryExpression() { SpelNodeImpl start = eatStartNode(); // always a start node List<SpelNodeImpl> nodes = null; SpelNodeImpl node = eatNode(); while (node != null) { if (nodes == null) { nodes = new ArrayList<>(4); nodes.add(start); } nodes.add(node); node = eatNode(); } if (start == null || nodes == null) { return start; } return new CompoundExpression(start.getStartPosition(), nodes.get(nodes.size() - 1).getEndPosition(), nodes.toArray(new SpelNodeImpl[0])); }
@Override public void setValue(ExpressionState expressionState, @Nullable Object newValue) throws EvaluationException { throw new SpelEvaluationException(getStartPosition(), SpelMessage.SETVALUE_NOT_SUPPORTED, getClass()); }
private boolean getBooleanValue(ExpressionState state, SpelNodeImpl operand) { try { Boolean value = operand.getValue(state, Boolean.class); assertValueNotNull(value); return value; } catch (SpelEvaluationException ex) { ex.setPosition(operand.getStartPosition()); throw ex; } }
private boolean getBooleanValue(ExpressionState state, SpelNodeImpl operand) { try { Boolean value = operand.getValue(state, Boolean.class); assertValueNotNull(value); return value; } catch (SpelEvaluationException ee) { ee.setPosition(operand.getStartPosition()); throw ee; } }
throw new SpelEvaluationException(leftOp.getStartPosition(), SpelMessage.INVALID_FIRST_OPERAND_FOR_MATCHES_OPERATOR, (Object) null); throw new SpelEvaluationException(rightOp.getStartPosition(), SpelMessage.INVALID_SECOND_OPERAND_FOR_MATCHES_OPERATOR, right); rightOp.getStartPosition(), ex, SpelMessage.INVALID_PATTERN, right); rightOp.getStartPosition(), ex, SpelMessage.FLAWED_PATTERN, right);
protected ValueRef getValueRef(ExpressionState state) throws EvaluationException { throw new SpelEvaluationException(getStartPosition(), SpelMessage.NOT_ASSIGNABLE, toStringAST()); }
/** * Eat an identifier, possibly qualified (meaning that it is dotted). * TODO AndyC Could create complete identifiers (a.b.c) here rather than a sequence of them? (a, b, c) */ private SpelNodeImpl eatPossiblyQualifiedId() { Deque<SpelNodeImpl> qualifiedIdPieces = new ArrayDeque<>(); Token node = peekToken(); while (isValidQualifiedId(node)) { nextToken(); if (node.kind != TokenKind.DOT) { qualifiedIdPieces.add(new Identifier(node.stringValue(), node.startPos, node.endPos)); } node = peekToken(); } if (qualifiedIdPieces.isEmpty()) { if (node == null) { throw internalException( this.expressionString.length(), SpelMessage.OOD); } throw internalException(node.startPos, SpelMessage.NOT_EXPECTED_TOKEN, "qualified ID", node.getKind().toString().toLowerCase()); } return new QualifiedIdentifier(qualifiedIdPieces.getFirst().getStartPosition(), qualifiedIdPieces.getLast().getEndPosition(), qualifiedIdPieces.toArray(new SpelNodeImpl[0])); }
@Nullable private SpelNodeImpl eatPrimaryExpression() { SpelNodeImpl start = eatStartNode(); // always a start node List<SpelNodeImpl> nodes = null; SpelNodeImpl node = eatNode(); while (node != null) { if (nodes == null) { nodes = new ArrayList<>(4); nodes.add(start); } nodes.add(node); node = eatNode(); } if (start == null || nodes == null) { return start; } return new CompoundExpression(toPos(start.getStartPosition(), nodes.get(nodes.size() - 1).getEndPosition()), nodes.toArray(new SpelNodeImpl[0])); }
private boolean getBooleanValue(ExpressionState state, SpelNodeImpl operand) { try { Boolean value = operand.getValue(state, Boolean.class); assertValueNotNull(value); return value; } catch (SpelEvaluationException ex) { ex.setPosition(operand.getStartPosition()); throw ex; } }
private boolean getBooleanValue(ExpressionState state, SpelNodeImpl operand) { try { Boolean value = operand.getValue(state, Boolean.class); assertValueNotNull(value); return value; } catch (SpelEvaluationException ee) { ee.setPosition(operand.getStartPosition()); throw ee; } }
BooleanTypedValue result; if (rightValue == null || !(rightValue instanceof Class)) { throw new SpelEvaluationException(getRightOperand().getStartPosition(), SpelMessage.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND, (rightValue == null ? "null" : rightValue.getClass().getName()));
/** * Returns a boolean based on whether a value is in the range expressed. The first * operand is any value whilst the second is a list of two values - those two values * being the bounds allowed for the first operand (inclusive). * @param state the expression state * @return true if the left operand is in the range specified, false otherwise * @throws EvaluationException if there is a problem evaluating the expression */ @Override public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException { Object left = getLeftOperand().getValueInternal(state).getValue(); Object right = getRightOperand().getValueInternal(state).getValue(); if (!(right instanceof List) || ((List<?>) right).size() != 2) { throw new SpelEvaluationException(getRightOperand().getStartPosition(), SpelMessage.BETWEEN_RIGHT_OPERAND_MUST_BE_TWO_ELEMENT_LIST); } List<?> list = (List<?>) right; Object low = list.get(0); Object high = list.get(1); TypeComparator comp = state.getTypeComparator(); try { return BooleanTypedValue.forValue(comp.compare(left, low) >= 0 && comp.compare(left, high) <= 0); } catch (SpelEvaluationException ex) { ex.setPosition(getStartPosition()); throw ex; } }
throw new SpelEvaluationException(selectionCriteria.getStartPosition(), SpelMessage.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN); throw new SpelEvaluationException(selectionCriteria.getStartPosition(), SpelMessage.RESULT_OF_SELECTION_CRITERIA_IS_NOT_BOOLEAN);
if (ex.getMessageCode() == SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES) { throw new SpelEvaluationException(operand.getStartPosition(), SpelMessage.OPERAND_NOT_INCREMENTABLE, operand.toStringAST()); throw new SpelEvaluationException(operand.getStartPosition(), SpelMessage.OPERAND_NOT_INCREMENTABLE);
if (ex.getMessageCode() == SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES) { throw new SpelEvaluationException(operand.getStartPosition(), SpelMessage.OPERAND_NOT_DECREMENTABLE, operand.toStringAST()); throw new SpelEvaluationException(operand.getStartPosition(), SpelMessage.OPERAND_NOT_DECREMENTABLE);
ex.setPosition(nextNode.getStartPosition()); throw ex;
@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()); }