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

The following examples show how to use org.springframework.expression.spel.ast.Operator. 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: OperatorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testOperatorNames() throws Exception {
	Operator node = getOperatorNode((SpelExpression)parser.parseExpression("1==3"));
	assertEquals("==",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("1!=3"));
	assertEquals("!=",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3/3"));
	assertEquals("/",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3+3"));
	assertEquals("+",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3-3"));
	assertEquals("-",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3<4"));
	assertEquals("<",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3<=4"));
	assertEquals("<=",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3*4"));
	assertEquals("*",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3%4"));
	assertEquals("%",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3>=4"));
	assertEquals(">=",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3 between 4"));
	assertEquals("between",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3 ^ 4"));
	assertEquals("^",node.getOperatorName());
}
 
Example #2
Source File: OperatorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private Operator findOperator(SpelNode node) {
	if (node instanceof Operator) {
		return (Operator) node;
	}
	int childCount = node.getChildCount();
	for (int i = 0; i < childCount; i++) {
		Operator possible = findOperator(node.getChild(i));
		if (possible != null) {
			return possible;
		}
	}
	return null;
}
 
Example #3
Source File: OperatorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testOperatorNames() throws Exception {
	Operator node = getOperatorNode((SpelExpression)parser.parseExpression("1==3"));
	assertEquals("==",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("1!=3"));
	assertEquals("!=",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3/3"));
	assertEquals("/",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3+3"));
	assertEquals("+",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3-3"));
	assertEquals("-",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3<4"));
	assertEquals("<",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3<=4"));
	assertEquals("<=",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3*4"));
	assertEquals("*",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3%4"));
	assertEquals("%",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3>=4"));
	assertEquals(">=",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3 between 4"));
	assertEquals("between",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3 ^ 4"));
	assertEquals("^",node.getOperatorName());
}
 
Example #4
Source File: OperatorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private Operator findOperator(SpelNode node) {
	if (node instanceof Operator) {
		return (Operator) node;
	}
	int childCount = node.getChildCount();
	for (int i = 0; i < childCount; i++) {
		Operator possible = findOperator(node.getChild(i));
		if (possible != null) {
			return possible;
		}
	}
	return null;
}
 
Example #5
Source File: OperatorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testOperatorNames() throws Exception {
	Operator node = getOperatorNode((SpelExpression)parser.parseExpression("1==3"));
	assertEquals("==",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("1!=3"));
	assertEquals("!=",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3/3"));
	assertEquals("/",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3+3"));
	assertEquals("+",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3-3"));
	assertEquals("-",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3<4"));
	assertEquals("<",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3<=4"));
	assertEquals("<=",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3*4"));
	assertEquals("*",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3%4"));
	assertEquals("%",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3>=4"));
	assertEquals(">=",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3 between 4"));
	assertEquals("between",node.getOperatorName());

	node = getOperatorNode((SpelExpression)parser.parseExpression("3 ^ 4"));
	assertEquals("^",node.getOperatorName());
}
 
Example #6
Source File: OperatorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private Operator findOperator(SpelNode node) {
	if (node instanceof Operator) {
		return (Operator) node;
	}
	int childCount = node.getChildCount();
	for (int i = 0; i < childCount; i++) {
		Operator possible = findOperator(node.getChild(i));
		if (possible != null) {
			return possible;
		}
	}
	return null;
}
 
Example #7
Source File: OperatorTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private Operator getOperatorNode(SpelExpression expr) {
	SpelNode node = expr.getAST();
	return findOperator(node);
}
 
Example #8
Source File: OperatorTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
private Operator getOperatorNode(SpelExpression expr) {
	SpelNode node = expr.getAST();
	return findOperator(node);
}
 
Example #9
Source File: OperatorTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private Operator getOperatorNode(SpelExpression expr) {
	SpelNode node = expr.getAST();
	return findOperator(node);
}