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
{
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;
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;
}
Value.Type resultType,
ParseContext context) {
- if(context == null) {
- context = DEFAULT_PARSE_CONTEXT;
- }
-
List<Token> tokens = trimSpaces(
ExpressionTokenizer.tokenize(exprType, exprStr, context));
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>} = " +
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)));
}
}
public Function getExpressionFunction(String name) {
- return DefaultFunctions.getFunction(name);
+ return DefaultFunctions.LOOKUP.getFunction(name);
}
}