本文整理匯總了Java中org.springframework.expression.spel.ast.Operator類的典型用法代碼示例。如果您正苦於以下問題:Java Operator類的具體用法?Java Operator怎麽用?Java Operator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Operator類屬於org.springframework.expression.spel.ast包,在下文中一共展示了Operator類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handle
import org.springframework.expression.spel.ast.Operator; //導入依賴的package包/類
private void handle(SpelNode node, Class<?> expressionRoot) throws ExpressionValidationException{
if (node instanceof MethodReference) {
verify((MethodReference) node, expressionRoot);
} else if (node instanceof Operator) {
Operator operator = (Operator) node;
handle(operator.getLeftOperand(), expressionRoot);
handle(operator.getRightOperand(), expressionRoot);
} else if (node != null) {
for(int i=0; i<node.getChildCount(); i++) {
SpelNode child = node.getChild(i);
if (child instanceof VariableReference ||
child instanceof TypeReference ||
child instanceof BeanReference) {
// stop inspecting if it's a variable or type reference.
// We can handle this later if we get smart about resolving these
break;
}
handle(child, expressionRoot);
}
}
}
示例2: testOperatorNames
import org.springframework.expression.spel.ast.Operator; //導入依賴的package包/類
@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());
}
示例3: findOperator
import org.springframework.expression.spel.ast.Operator; //導入依賴的package包/類
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;
}
示例4: findNode
import org.springframework.expression.spel.ast.Operator; //導入依賴的package包/類
private SpelNode findNode(SpelNode node, Class<Operator> clazz) {
if (clazz.isAssignableFrom(node.getClass())) {
return node;
}
int childCount = node.getChildCount();
for (int i=0;i<childCount;i++) {
SpelNode possible = findNode(node.getChild(i),clazz);
if (possible!=null) {
return possible;
}
}
return null;
}
示例5: getOperatorNode
import org.springframework.expression.spel.ast.Operator; //導入依賴的package包/類
private Operator getOperatorNode(SpelExpression expr) {
SpelNode node = expr.getAST();
return findOperator(node);
}
示例6: getOperatorNode
import org.springframework.expression.spel.ast.Operator; //導入依賴的package包/類
private Operator getOperatorNode(SpelExpression e) {
SpelNode node = e.getAST();
return (Operator)findNode(node,Operator.class);
}