Browse Source

handle alternate true/false constant values

git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1179 f203690c-595d-4dc9-a70b-905162fa7fd2
tags/jackcess-2.2.0
James Ahlborn 5 years ago
parent
commit
62f7289248

+ 11
- 4
src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java View File

@@ -88,7 +88,8 @@ public class Expressionator
setWordType(WordType.OP, "+", "-", "*", "/", "\\", "^", "&", "mod");
setWordType(WordType.COMP, "<", "<=", ">", ">=", "=", "<>");
setWordType(WordType.LOG_OP, "and", "or", "eqv", "xor", "imp");
setWordType(WordType.CONST, "true", "false", "null");
setWordType(WordType.CONST, "true", "false", "null", "on", "off",
"yes", "no");
setWordType(WordType.SPEC_OP_PREFIX, "is", "like", "between", "in", "not");
// "X is null", "X is not null", "X like P", "X between A and B",
// "X not between A and B", "X in (A, B, C...)", "X not in (A, B, C...)",
@@ -96,6 +97,11 @@ public class Expressionator
setWordType(WordType.DELIM, ".", "!", ",", "(", ")");
}

private static final Collection<String> TRUE_STRS =
Arrays.asList("true", "yes", "on");
private static final Collection<String> FALSE_STRS =
Arrays.asList("false", "no", "off");

private interface OpType {}

private enum UnaryOp implements OpType {
@@ -961,11 +967,12 @@ public class Expressionator

private static void parseConstExpression(Token firstTok, TokBuf buf) {
Expr constExpr = null;
if("true".equalsIgnoreCase(firstTok.getValueStr())) {
String tokStr = firstTok.getValueStr().toLowerCase();
if(TRUE_STRS.contains(tokStr)) {
constExpr = TRUE_VALUE;
} else if("false".equalsIgnoreCase(firstTok.getValueStr())) {
} else if(FALSE_STRS.contains(tokStr)) {
constExpr = FALSE_VALUE;
} else if("null".equalsIgnoreCase(firstTok.getValueStr())) {
} else if("null".equals(tokStr)) {
constExpr = NULL_VALUE;
} else {
throw new ParseException("Unexpected CONST word "

Loading…
Cancel
Save