當前位置: 首頁>>代碼示例>>Java>>正文


Java Operator類代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:massfords,項目名稱:spel-maven-plugin,代碼行數:22,代碼來源:ExpressionValidator.java

示例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());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:39,代碼來源:OperatorTests.java

示例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;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:14,代碼來源:OperatorTests.java

示例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;
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:14,代碼來源:OperatorTests.java

示例5: getOperatorNode

import org.springframework.expression.spel.ast.Operator; //導入依賴的package包/類
private Operator getOperatorNode(SpelExpression expr) {
	SpelNode node = expr.getAST();
	return findOperator(node);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:5,代碼來源:OperatorTests.java

示例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);
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:5,代碼來源:OperatorTests.java


注:本文中的org.springframework.expression.spel.ast.Operator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。