From a6f33b99a6df0a70305e6e24b1770b3a9b818962 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Wed, 27 Jun 2018 03:50:11 +0000 Subject: [PATCH] ditch default parse context git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1175 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../jackcess/impl/expr/DefaultFunctions.java | 5 +---- .../jackcess/impl/expr/Expressionator.java | 17 ----------------- .../jackcess/impl/expr/ExpressionatorTest.java | 8 +++++--- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java index 7acca2c..b691d64 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java @@ -50,15 +50,12 @@ public class DefaultFunctions public static final FunctionLookup LOOKUP = new FunctionLookup() { public Function getFunction(String name) { - return DefaultFunctions.getFunction(name); + return FUNCS.get(DatabaseImpl.toLookupName(name)); } }; private DefaultFunctions() {} - public static Function getFunction(String name) { - return FUNCS.get(DatabaseImpl.toLookupName(name)); - } public static abstract class BaseFunction implements Function { 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 75b7950..993f47d 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java @@ -35,7 +35,6 @@ import java.util.Set; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import com.healthmarketscience.jackcess.DatabaseBuilder; import com.healthmarketscience.jackcess.expr.EvalContext; import com.healthmarketscience.jackcess.expr.EvalException; import com.healthmarketscience.jackcess.expr.Expression; @@ -71,18 +70,6 @@ public class Expressionator public Function getExpressionFunction(String name); } - public static final ParseContext DEFAULT_PARSE_CONTEXT = new ParseContext() { - public TemporalConfig getTemporalConfig() { - return TemporalConfig.US_TEMPORAL_CONFIG; - } - public SimpleDateFormat createDateFormat(String formatStr) { - return DatabaseBuilder.createDateFormat(formatStr); - } - public Function getExpressionFunction(String name) { - return DefaultFunctions.getFunction(name); - } - }; - private enum WordType { OP, COMP, LOG_OP, CONST, SPEC_OP_PREFIX, DELIM; } @@ -414,10 +401,6 @@ public class Expressionator Value.Type resultType, ParseContext context) { - if(context == null) { - context = DEFAULT_PARSE_CONTEXT; - } - List tokens = trimSpaces( ExpressionTokenizer.tokenize(exprType, exprStr, context)); diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java index 2f6e738..39745d0 100644 --- a/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java @@ -343,7 +343,8 @@ public class ExpressionatorTest extends TestCase private static void validateExpr(String exprStr, String debugStr, String cleanStr) { Expression expr = Expressionator.parse( - Expressionator.Type.FIELD_VALIDATOR, exprStr, null, null); + Expressionator.Type.FIELD_VALIDATOR, exprStr, null, + new TestParseContext()); String foundDebugStr = expr.toDebugString(); if(foundDebugStr.startsWith("")) { assertEquals("{{} = " + @@ -381,7 +382,8 @@ public class ExpressionatorTest extends TestCase private static Boolean evalCondition(String exprStr, String thisVal) { Expression expr = Expressionator.parse( - Expressionator.Type.FIELD_VALIDATOR, exprStr, null, new TestParseContext()); + Expressionator.Type.FIELD_VALIDATOR, exprStr, null, + new TestParseContext()); return (Boolean)expr.eval(new TestEvalContext(BuiltinOperators.toValue(thisVal))); } @@ -410,7 +412,7 @@ public class ExpressionatorTest extends TestCase } public Function getExpressionFunction(String name) { - return DefaultFunctions.getFunction(name); + return DefaultFunctions.LOOKUP.getFunction(name); } } -- 2.39.5