]> source.dussan.org Git - jackcess.git/commitdiff
handle alternate true/false constant values
authorJames Ahlborn <jtahlborn@yahoo.com>
Fri, 13 Jul 2018 20:29:25 +0000 (20:29 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Fri, 13 Jul 2018 20:29:25 +0000 (20:29 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1179 f203690c-595d-4dc9-a70b-905162fa7fd2

src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java

index 96deb27b99df75370eb7df74728725cfb7e61a83..4988f3eba00392f4623738cacb0e8267950ac343 100644 (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 "