]> source.dussan.org Git - jackcess.git/commitdiff
ditch default parse context
authorJames Ahlborn <jtahlborn@yahoo.com>
Wed, 27 Jun 2018 03:50:11 +0000 (03:50 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Wed, 27 Jun 2018 03:50:11 +0000 (03:50 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1175 f203690c-595d-4dc9-a70b-905162fa7fd2

src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java
src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java
src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java

index 7acca2c653b5286e5e9e13aac72bbe99f8a23c45..b691d64d0ddca18d9b138cd99b7b1c2fc4e0b04c 100644 (file)
@@ -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
   {
index 75b7950663ff86d56bca574274fe070e163c1ece..993f47d8ff8e8416ac7c6d4c531f5f8a6fae8e3a 100644 (file)
@@ -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<Token> tokens = trimSpaces(
         ExpressionTokenizer.tokenize(exprType, exprStr, context));
 
index 2f6e738a2890966e5c545285befbad21b825b0ff..39745d033a82833599c50c8369eebcaf32820ab3 100644 (file)
@@ -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("<EImplicitCompOp>")) {
       assertEquals("<EImplicitCompOp>{<EThisValue>{<THIS_COL>} = " +
@@ -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);
     }
   }