aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2018-06-27 03:50:11 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2018-06-27 03:50:11 +0000
commita6f33b99a6df0a70305e6e24b1770b3a9b818962 (patch)
treefee3103ff6277d83a06456650d95e114edbb4e3e
parent1595c573b1a881de80a2803a70caa448e7404314 (diff)
downloadjackcess-a6f33b99a6df0a70305e6e24b1770b3a9b818962.tar.gz
jackcess-a6f33b99a6df0a70305e6e24b1770b3a9b818962.zip
ditch default parse context
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1175 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java5
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java17
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java8
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<Token> 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("<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);
}
}