diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2018-07-13 20:29:25 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2018-07-13 20:29:25 +0000 |
commit | 62f72892480c45b56d1880891478e6a9757a3779 (patch) | |
tree | 123a6701cb4541d019f112ff92d83728e6ea97fc /src | |
parent | 17d5d661ac7d4ca3f59747b9f6a992b16ea8e3cd (diff) | |
download | jackcess-62f72892480c45b56d1880891478e6a9757a3779.tar.gz jackcess-62f72892480c45b56d1880891478e6a9757a3779.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java b/src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java index 96deb27..4988f3e 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java @@ -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 " |