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


Java XPathUnionExpr類代碼示例

本文整理匯總了Java中org.javarosa.xpath.expr.XPathUnionExpr的典型用法代碼示例。如果您正苦於以下問題:Java XPathUnionExpr類的具體用法?Java XPathUnionExpr怎麽用?Java XPathUnionExpr使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XPathUnionExpr類屬於org.javarosa.xpath.expr包,在下文中一共展示了XPathUnionExpr類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBinOpExpr

import org.javarosa.xpath.expr.XPathUnionExpr; //導入依賴的package包/類
private XPathBinaryOpExpr getBinOpExpr (int op, XPathExpression a, XPathExpression b) throws XPathSyntaxException {
	switch (op) {
	case Token.OR: return new XPathBoolExpr(XPathBoolExpr.OR, a, b);
	case Token.AND: return new XPathBoolExpr(XPathBoolExpr.AND, a, b);
	case Token.EQ: return new XPathEqExpr(true, a, b);
	case Token.NEQ: return new XPathEqExpr(false, a, b);
	case Token.LT: return new XPathCmpExpr(XPathCmpExpr.LT, a, b);
	case Token.LTE: return new XPathCmpExpr(XPathCmpExpr.LTE, a, b);
	case Token.GT: return new XPathCmpExpr(XPathCmpExpr.GT, a, b);
	case Token.GTE: return new XPathCmpExpr(XPathCmpExpr.GTE, a, b);
	case Token.PLUS: return new XPathArithExpr(XPathArithExpr.ADD, a, b);
	case Token.MINUS: return new XPathArithExpr(XPathArithExpr.SUBTRACT, a, b);
	case Token.MULT: return new XPathArithExpr(XPathArithExpr.MULTIPLY, a, b);
	case Token.DIV: return new XPathArithExpr(XPathArithExpr.DIVIDE, a, b);
	case Token.MOD: return new XPathArithExpr(XPathArithExpr.MODULO, a, b);
	case Token.UNION: return new XPathUnionExpr(a, b);
	default: throw new XPathSyntaxException();
	}
}
 
開發者ID:medic,項目名稱:javarosa,代碼行數:20,代碼來源:ASTNodeBinaryOp.java

示例2: getBinOpExpr

import org.javarosa.xpath.expr.XPathUnionExpr; //導入依賴的package包/類
private XPathBinaryOpExpr getBinOpExpr(int op, XPathExpression a, XPathExpression b) throws XPathSyntaxException {
    switch (op) {
        case Token.OR:
            return new XPathBoolExpr(XPathBoolExpr.OR, a, b);
        case Token.AND:
            return new XPathBoolExpr(XPathBoolExpr.AND, a, b);
        case Token.EQ:
            return new XPathEqExpr(XPathEqExpr.EQ, a, b);
        case Token.NEQ:
            return new XPathEqExpr(XPathEqExpr.NEQ, a, b);
        case Token.LT:
            return new XPathCmpExpr(XPathCmpExpr.LT, a, b);
        case Token.LTE:
            return new XPathCmpExpr(XPathCmpExpr.LTE, a, b);
        case Token.GT:
            return new XPathCmpExpr(XPathCmpExpr.GT, a, b);
        case Token.GTE:
            return new XPathCmpExpr(XPathCmpExpr.GTE, a, b);
        case Token.PLUS:
            return new XPathArithExpr(XPathArithExpr.ADD, a, b);
        case Token.MINUS:
            return new XPathArithExpr(XPathArithExpr.SUBTRACT, a, b);
        case Token.MULT:
            return new XPathArithExpr(XPathArithExpr.MULTIPLY, a, b);
        case Token.DIV:
            return new XPathArithExpr(XPathArithExpr.DIVIDE, a, b);
        case Token.MOD:
            return new XPathArithExpr(XPathArithExpr.MODULO, a, b);
        case Token.UNION:
            return new XPathUnionExpr(a, b);
        default:
            throw new XPathSyntaxException();
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:35,代碼來源:ASTNodeBinaryOp.java

示例3: equalityForDifferentBinaryOps

import org.javarosa.xpath.expr.XPathUnionExpr; //導入依賴的package包/類
/**
 * Extensive checks of binary op expression equality logic, because we all
 * know 'a > b' isn't the same as 'a = b', but we don't always write code
 * that knows that...
 */
@Test
public void equalityForDifferentBinaryOps() {
    XPathStringLiteral leftStringExpr = new XPathStringLiteral("left side");
    XPathNumericLiteral zero = new XPathNumericLiteral(0d);

    // Setup expressions to test equality over.
    // Note: these binary expressions make semantic sense
    XPathArithExpr additionExpr = new XPathArithExpr(XPathArithExpr.ADD, leftStringExpr, zero);
    XPathArithExpr additionExprClone = new XPathArithExpr(XPathArithExpr.ADD, leftStringExpr, zero);
    XPathArithExpr subtractExpr = new XPathArithExpr(XPathArithExpr.SUBTRACT, leftStringExpr, zero);

    XPathBoolExpr andExpr = new XPathBoolExpr(XPathBoolExpr.AND, leftStringExpr, zero);
    XPathBoolExpr andExprClone = new XPathBoolExpr(XPathBoolExpr.AND, leftStringExpr, zero);
    XPathBoolExpr orExpr = new XPathBoolExpr(XPathBoolExpr.OR, leftStringExpr, zero);

    XPathCmpExpr lessThanExpr = new XPathCmpExpr(XPathCmpExpr.LT, leftStringExpr, zero);
    XPathCmpExpr greaterThanExpr = new XPathCmpExpr(XPathCmpExpr.GT, leftStringExpr, zero);

    XPathEqExpr eqExpr = new XPathEqExpr(XPathEqExpr.EQ, leftStringExpr, zero);
    XPathEqExpr neqExpr = new XPathEqExpr(XPathEqExpr.NEQ, leftStringExpr, zero);

    XPathUnionExpr union = new XPathUnionExpr(leftStringExpr, zero);
    XPathUnionExpr differentUnion = new XPathUnionExpr(zero, zero);

    // basic equality tests over same subclass
    Assert.assertEquals("Same + expression reference is equal", additionExpr, additionExpr);
    Assert.assertEquals("Same + expression is equal", additionExpr, additionExprClone);
    Assert.assertNotEquals("+ not equal to  -", additionExpr, subtractExpr);
    Assert.assertEquals("Same && expression reference is equal", andExpr, andExpr);
    Assert.assertEquals("Same && expression is equal", andExpr, andExprClone);
    Assert.assertNotEquals("&& not equal to ||", andExpr, orExpr);
    Assert.assertEquals("Same < expression is equal", lessThanExpr, lessThanExpr);
    Assert.assertNotEquals("< not equal to  >", lessThanExpr, greaterThanExpr);
    Assert.assertEquals("Same == expression is equal", eqExpr, eqExpr);
    Assert.assertNotEquals("== not equal to !=", eqExpr, neqExpr);

    // make sure different binary expressions with same op code aren't equal
    Assert.assertNotEquals("+ not equal to &&", additionExpr, andExpr);
    Assert.assertNotEquals("+ not equal to <", additionExpr, lessThanExpr);
    Assert.assertNotEquals("+ not equal to ==", additionExpr, eqExpr);
    Assert.assertNotEquals("- not equal to ||", subtractExpr, orExpr);
    Assert.assertNotEquals("- not equal to >", subtractExpr, greaterThanExpr);
    Assert.assertNotEquals("- not equal to !=", subtractExpr, neqExpr);

    // make sure union equality, which doesn't have an op code, works
    Assert.assertEquals("same union instance is equal to itself", union, union);
    Assert.assertNotEquals(union, differentUnion);
    Assert.assertNotEquals("+ not equal to union", additionExpr, union);
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:55,代碼來源:XPathBinaryOpExprTest.java


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