org.springframework.expression.spel.ast.OpAnd Java Examples

The following examples show how to use org.springframework.expression.spel.ast.OpAnd. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpelParserTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #2
Source File: SpelParserTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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());
}
 
Example #3
Source File: SpelParserTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void positionalInformation() throws EvaluationException, ParseException {
	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());
}