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


Java Token類代碼示例

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


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

示例1: getBinOpExpr

import org.javarosa.xpath.parser.Token; //導入依賴的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: build

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
public XPathExpression build() throws XPathSyntaxException {
	if (content.size() == 1) {
		if (getType(0) == CHILD) {
			return ((ASTNode)content.elementAt(0)).build();
		} else {
			switch (getTokenType(0)) {
			case Token.NUM: return new XPathNumericLiteral((Double)getToken(0).val);
			case Token.STR: return new XPathStringLiteral((String)getToken(0).val);
			case Token.VAR: return new XPathVariableReference((XPathQName)getToken(0).val);
			default: throw new XPathSyntaxException();
			}
		}
	} else {
		throw new XPathSyntaxException();
	}
}
 
開發者ID:medic,項目名稱:javarosa,代碼行數:17,代碼來源:ASTNodeAbstractExpr.java

示例3: build

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
public XPathExpression build() throws XPathSyntaxException {
    if (content.size() == 1) {
        if (getType(0) == CHILD) {
            return ((ASTNode)content.elementAt(0)).build();
        } else {
            switch (getTokenType(0)) {
                case Token.NUM:
                    return new XPathNumericLiteral((Double)getToken(0).val);
                case Token.STR:
                    return new XPathStringLiteral((String)getToken(0).val);
                case Token.VAR:
                    return new XPathVariableReference((XPathQName)getToken(0).val);
                default:
                    throw new XPathSyntaxException();
            }
        }
    } else {
        throw new XPathSyntaxException();
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:21,代碼來源:ASTNodeAbstractExpr.java

示例4: build

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
@Override
public XPathExpression build() throws XPathSyntaxException {
    if (size() == 1) {
        if (getType(0) == CHILD) {
            return ((ASTNode)content.get(0)).build();
        } else {
            switch (getTokenType(0)) {
                case Token.NUM:
                    return new XPathNumericLiteral((Double)getToken(0).val);
                case Token.STR:
                    return new XPathStringLiteral((String)getToken(0).val);
                case Token.VAR:
                    return new XPathVariableReference((XPathQName)getToken(0).val);
                default:
                    throw new XPathSyntaxException();
            }
        }
    } else {
        throw new XPathSyntaxException();
    }
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:22,代碼來源:ASTNodeAbstractExpr.java

示例5: isStep

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
/**
 * true if 'node' is potentially a step, as opposed to a filter expr
 */
public boolean isStep() {
    if (size() > 0) {
        int type = getTokenType(0);
        if (type == Token.QNAME ||
                type == Token.WILDCARD ||
                type == Token.NSWILDCARD ||
                type == Token.AT ||
                type == Token.DOT ||
                type == Token.DBL_DOT) {
            return true;
        } else if (content.get(0) instanceof ASTNodeFunctionCall) {
            String name = ((ASTNodeFunctionCall)content.get(0)).name.toString();
            return (name.equals("node") || name.equals("text") || name.equals("comment") || name.equals("processing-instruction"));
        } else {
            return false;
        }
    } else {
        return false;
    }
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:24,代碼來源:ASTNodeAbstractExpr.java

示例6: isTerminal

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
public boolean isTerminal () {
	if (content.size() == 1) {
		int type = getTokenType(0);
		return (type == Token.NUM || type == Token.STR || type == Token.VAR);
	} else {
		return false;
	}
}
 
開發者ID:medic,項目名稱:javarosa,代碼行數:9,代碼來源:ASTNodeAbstractExpr.java

示例7: getType

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
public int getType (int i) {
	Object o = content.elementAt(i);
	if (o instanceof Token)
		return TOKEN;
	else if (o instanceof ASTNode)
		return CHILD;
	else
		return -1;
}
 
開發者ID:medic,項目名稱:javarosa,代碼行數:10,代碼來源:ASTNodeAbstractExpr.java

示例8: build

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
public XPathExpression build() throws XPathSyntaxException {
	Vector<XPathStep> steps = new Vector<XPathStep>();
	XPathExpression filtExpr = null;
	int offset = isAbsolute() ? 1 : 0;
	for (int i = 0; i < clauses.size() + offset; i++) {
		if (offset == 0 || i > 0) {
			if (clauses.elementAt(i - offset) instanceof ASTNodePathStep) {
				steps.addElement(((ASTNodePathStep)clauses.elementAt(i - offset)).getStep());
			} else {
				filtExpr = clauses.elementAt(i - offset).build();
			}
		}
			
		if (i < separators.size()) {
			if (Parser.vectInt(separators, i) == Token.DBL_SLASH) {
				steps.addElement(XPathStep.ABBR_DESCENDANTS());
			}
		}
	}

	XPathStep[] stepArr = new XPathStep[steps.size()];
	for (int i = 0; i < stepArr.length; i++)
		stepArr[i] = steps.elementAt(i);
	
	if (filtExpr == null) {
		return new XPathPathExpr(isAbsolute() ? XPathPathExpr.INIT_CONTEXT_ROOT : XPathPathExpr.INIT_CONTEXT_RELATIVE, stepArr);
	} else {
		if (filtExpr instanceof XPathFilterExpr) {
			return new XPathPathExpr((XPathFilterExpr)filtExpr, stepArr);
		} else {
			return new XPathPathExpr(new XPathFilterExpr(filtExpr, new XPathExpression[0]), stepArr);
		}
	}		
}
 
開發者ID:medic,項目名稱:javarosa,代碼行數:35,代碼來源:ASTNodeLocPath.java

示例9: validateNodeTypeTest

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
public static boolean validateNodeTypeTest (ASTNodeFunctionCall f) {
	String name = f.name.toString();
	if (name.equals("node") || name.equals("text") || name.equals("comment") || name.equals("processing-instruction")) {
		if (f.args.size() == 0) {
			return true;
		} else if (name.equals("processing-instruction") && f.args.size() == 1) {
			ASTNodeAbstractExpr x = (ASTNodeAbstractExpr)f.args.elementAt(0);
			return x.content.size() == 1 && x.getTokenType(0) == Token.STR;
		} else {
			return false;
		}
	} else {
		return false;
	}
}
 
開發者ID:medic,項目名稱:javarosa,代碼行數:16,代碼來源:ASTNodePathStep.java

示例10: getBinOpExpr

import org.javarosa.xpath.parser.Token; //導入依賴的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

示例11: isTerminal

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
public boolean isTerminal() {
    if (content.size() == 1) {
        int type = getTokenType(0);
        return (type == Token.NUM || type == Token.STR || type == Token.VAR);
    } else {
        return false;
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:9,代碼來源:ASTNodeAbstractExpr.java

示例12: getType

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
public int getType(int i) {
    Object o = content.elementAt(i);
    if (o instanceof Token)
        return TOKEN;
    else if (o instanceof ASTNode)
        return CHILD;
    else
        return -1;
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:10,代碼來源:ASTNodeAbstractExpr.java

示例13: build

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
public XPathExpression build() throws XPathSyntaxException {
    Vector<XPathStep> steps = new Vector<XPathStep>();
    XPathExpression filtExpr = null;
    int offset = isAbsolute() ? 1 : 0;
    for (int i = 0; i < clauses.size() + offset; i++) {
        if (offset == 0 || i > 0) {
            if (clauses.elementAt(i - offset) instanceof ASTNodePathStep) {
                steps.addElement(((ASTNodePathStep)clauses.elementAt(i - offset)).getStep());
            } else {
                filtExpr = clauses.elementAt(i - offset).build();
            }
        }

        if (i < separators.size()) {
            if (Parser.vectInt(separators, i) == Token.DBL_SLASH) {
                steps.addElement(XPathStep.ABBR_DESCENDANTS());
            }
        }
    }

    XPathStep[] stepArr = new XPathStep[steps.size()];
    for (int i = 0; i < stepArr.length; i++)
        stepArr[i] = steps.elementAt(i);

    if (filtExpr == null) {
        return new XPathPathExpr(isAbsolute() ? XPathPathExpr.INIT_CONTEXT_ROOT : XPathPathExpr.INIT_CONTEXT_RELATIVE, stepArr);
    } else {
        if (filtExpr instanceof XPathFilterExpr) {
            return new XPathPathExpr((XPathFilterExpr)filtExpr, stepArr);
        } else {
            return new XPathPathExpr(new XPathFilterExpr(filtExpr, new XPathExpression[0]), stepArr);
        }
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:35,代碼來源:ASTNodeLocPath.java

示例14: validateNodeTypeTest

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
public static boolean validateNodeTypeTest(ASTNodeFunctionCall f) {
    String name = f.name.toString();
    if (name.equals("node") || name.equals("text") || name.equals("comment") || name.equals("processing-instruction")) {
        if (f.args.size() == 0) {
            return true;
        } else if (name.equals("processing-instruction") && f.args.size() == 1) {
            ASTNodeAbstractExpr x = (ASTNodeAbstractExpr)f.args.elementAt(0);
            return x.content.size() == 1 && x.getTokenType(0) == Token.STR;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:16,代碼來源:ASTNodePathStep.java

示例15: isTerminal

import org.javarosa.xpath.parser.Token; //導入依賴的package包/類
private boolean isTerminal() {
    if (size() == 1) {
        int type = getTokenType(0);
        return (type == Token.NUM || type == Token.STR || type == Token.VAR);
    } else {
        return false;
    }
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:9,代碼來源:ASTNodeAbstractExpr.java


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