本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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);
}
}
}
示例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;
}
}
示例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();
}
}
示例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;
}
}
示例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;
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
}