Browse Source

use specific exceptions for expr eval

git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/exprs@1146 f203690c-595d-4dc9-a70b-905162fa7fd2
tags/jackcess-2.2.0
James Ahlborn 6 years ago
parent
commit
9908a0afe9

+ 40
- 0
src/main/java/com/healthmarketscience/jackcess/expr/EvalException.java View File

@@ -0,0 +1,40 @@
/*
Copyright (c) 2018 James Ahlborn

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.healthmarketscience.jackcess.expr;


/**
* Base class for exceptions thrown during expression evaluation.
*
* @author James Ahlborn
*/
public class EvalException extends IllegalStateException
{
private static final long serialVersionUID = 20180330L;

public EvalException(String message) {
super(message);
}

public EvalException(Throwable cause) {
super(cause);
}

public EvalException(String message, Throwable cause) {
super(message, cause);
}
}

+ 39
- 0
src/main/java/com/healthmarketscience/jackcess/expr/ParseException.java View File

@@ -0,0 +1,39 @@
/*
Copyright (c) 2018 James Ahlborn

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.healthmarketscience.jackcess.expr;

/**
* Exception thrown when expression parsing fails.
*
* @author James Ahlborn
*/
public class ParseException extends EvalException
{
private static final long serialVersionUID = 20180330L;

public ParseException(String message) {
super(message);
}

public ParseException(Throwable cause) {
super(cause);
}

public ParseException(String message, Throwable cause) {
super(message, cause);
}
}

+ 3
- 2
src/main/java/com/healthmarketscience/jackcess/impl/expr/BaseValue.java View File

@@ -21,6 +21,7 @@ import java.util.Date;

import com.healthmarketscience.jackcess.expr.Value;
import com.healthmarketscience.jackcess.expr.EvalContext;
import com.healthmarketscience.jackcess.expr.EvalException;

/**
*
@@ -56,8 +57,8 @@ public abstract class BaseValue implements Value
throw invalidConversion(Value.Type.BIG_DEC);
}

private UnsupportedOperationException invalidConversion(Value.Type newType) {
return new UnsupportedOperationException(
private EvalException invalidConversion(Value.Type newType) {
return new EvalException(
getType() + " value cannot be converted to " + newType);
}


+ 12
- 11
src/main/java/com/healthmarketscience/jackcess/impl/expr/BuiltinOperators.java View File

@@ -23,6 +23,7 @@ import java.util.Date;
import java.util.regex.Pattern;

import com.healthmarketscience.jackcess.expr.EvalContext;
import com.healthmarketscience.jackcess.expr.EvalException;
import com.healthmarketscience.jackcess.expr.Value;
import com.healthmarketscience.jackcess.impl.ColumnImpl;

@@ -107,7 +108,7 @@ public class BuiltinOperators
case BIG_DEC:
return toValue(param1.getAsBigDecimal().negate());
default:
throw new RuntimeException("Unexpected type " + mathType);
throw new EvalException("Unexpected type " + mathType);
}
}

@@ -137,7 +138,7 @@ public class BuiltinOperators
case BIG_DEC:
return toValue(param1.getAsBigDecimal().add(param2.getAsBigDecimal()));
default:
throw new RuntimeException("Unexpected type " + mathType);
throw new EvalException("Unexpected type " + mathType);
}
}

@@ -165,7 +166,7 @@ public class BuiltinOperators
case BIG_DEC:
return toValue(param1.getAsBigDecimal().subtract(param2.getAsBigDecimal()));
default:
throw new RuntimeException("Unexpected type " + mathType);
throw new EvalException("Unexpected type " + mathType);
}
}

@@ -190,7 +191,7 @@ public class BuiltinOperators
case BIG_DEC:
return toValue(param1.getAsBigDecimal().multiply(param2.getAsBigDecimal()));
default:
throw new RuntimeException("Unexpected type " + mathType);
throw new EvalException("Unexpected type " + mathType);
}
}

@@ -224,7 +225,7 @@ public class BuiltinOperators
case BIG_DEC:
return toValue(param1.getAsBigDecimal().divide(param2.getAsBigDecimal()));
default:
throw new RuntimeException("Unexpected type " + mathType);
throw new EvalException("Unexpected type " + mathType);
}
}

@@ -237,7 +238,7 @@ public class BuiltinOperators
Value.Type mathType = getMathTypePrecedence(param1, param2,
CoercionType.GENERAL);
if(mathType == Value.Type.STRING) {
throw new RuntimeException("Unexpected type " + mathType);
throw new EvalException("Unexpected type " + mathType);
}
return toValue(param1.getAsLongInt() / param2.getAsLongInt());
}
@@ -272,7 +273,7 @@ public class BuiltinOperators
CoercionType.GENERAL);

if(mathType == Value.Type.STRING) {
throw new RuntimeException("Unexpected type " + mathType);
throw new EvalException("Unexpected type " + mathType);
}
return toValue(param1.getAsLongInt() % param2.getAsLongInt());
}
@@ -535,7 +536,7 @@ public class BuiltinOperators
case STRING:
// string comparison is only valid if _both_ params are strings
if(param1.getType() != param2.getType()) {
throw new RuntimeException("Unexpected type " + compareType);
throw new EvalException("Unexpected type " + compareType);
}
return param1.getAsString().compareToIgnoreCase(param2.getAsString());
// case DATE: break; promoted to double
@@ -548,7 +549,7 @@ public class BuiltinOperators
case BIG_DEC:
return param1.getAsBigDecimal().compareTo(param2.getAsBigDecimal());
default:
throw new RuntimeException("Unexpected type " + compareType);
throw new EvalException("Unexpected type " + compareType);
}
}

@@ -598,7 +599,7 @@ public class BuiltinOperators
case DATE_TIME:
return new DateTimeValue(d, fmt);
default:
throw new RuntimeException("Unexpected date/time type " + type);
throw new EvalException("Unexpected date/time type " + type);
}
}
@@ -632,7 +633,7 @@ public class BuiltinOperators
fmtStr = ctx.getTemporalConfig().getDefaultDateTimeFormat();
break;
default:
throw new RuntimeException("Unexpected date/time type " + type);
throw new EvalException("Unexpected date/time type " + type);
}
return ctx.createDateFormat(fmtStr);
}

+ 2
- 1
src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultDateFunctions.java View File

@@ -23,6 +23,7 @@ import java.util.Calendar;
import java.util.Date;

import com.healthmarketscience.jackcess.expr.EvalContext;
import com.healthmarketscience.jackcess.expr.EvalException;
import com.healthmarketscience.jackcess.expr.Function;
import com.healthmarketscience.jackcess.expr.Value;
import com.healthmarketscience.jackcess.impl.ColumnImpl;
@@ -204,7 +205,7 @@ public class DefaultDateFunctions
param = nonNullToDateValue(ctx, param);
if(param == null) {
// not a date/time
throw new IllegalStateException("Invalid date/time expression '" + param + "'");
throw new EvalException("Invalid date/time expression '" + param + "'");
}

Calendar cal = getDateValueFormat(ctx, param).getCalendar();

+ 8
- 7
src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java View File

@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.Map;

import com.healthmarketscience.jackcess.expr.EvalContext;
import com.healthmarketscience.jackcess.expr.EvalException;
import com.healthmarketscience.jackcess.expr.Function;
import com.healthmarketscience.jackcess.expr.Value;
import com.healthmarketscience.jackcess.impl.DatabaseImpl;
@@ -78,7 +79,7 @@ public class DefaultFunctions
if((num < _minParams) || (num > _maxParams)) {
String range = ((_minParams == _maxParams) ? "" + _minParams :
_minParams + " to " + _maxParams);
throw new IllegalArgumentException(
throw new EvalException(
"Invalid number of parameters " +
num + " passed, expected " + range);
}
@@ -311,7 +312,7 @@ public class DefaultFunctions
@Override
protected Value evalVar(EvalContext ctx, Value[] params) {
if((params.length % 2) != 0) {
throw new IllegalStateException("Odd number of parameters");
throw new EvalException("Odd number of parameters");
}
for(int i = 0; i < params.length; i+=2) {
if(params[i].getAsBoolean()) {
@@ -347,7 +348,7 @@ public class DefaultFunctions
protected Value eval1(EvalContext ctx, Value param1) {
int lv = param1.getAsLongInt();
if((lv < 0) || (lv > 255)) {
throw new IllegalStateException("Byte code '" + lv + "' out of range ");
throw new EvalException("Byte code '" + lv + "' out of range ");
}
return BuiltinOperators.toValue(lv);
}
@@ -393,7 +394,7 @@ public class DefaultFunctions
protected Value eval1(EvalContext ctx, Value param1) {
int lv = param1.getAsLongInt();
if((lv < Short.MIN_VALUE) || (lv > Short.MAX_VALUE)) {
throw new IllegalStateException("Int value '" + lv + "' out of range ");
throw new EvalException("Int value '" + lv + "' out of range ");
}
return BuiltinOperators.toValue(lv);
}
@@ -412,7 +413,7 @@ public class DefaultFunctions
protected Value eval1(EvalContext ctx, Value param1) {
Double dv = param1.getAsDouble();
if((dv < Float.MIN_VALUE) || (dv > Float.MAX_VALUE)) {
throw new IllegalStateException("Single value '" + dv + "' out of range ");
throw new EvalException("Single value '" + dv + "' out of range ");
}
return BuiltinOperators.toValue(dv.floatValue());
}
@@ -481,7 +482,7 @@ public class DefaultFunctions
vType = 14;
break;
default:
throw new RuntimeException("Unknown type " + type);
throw new EvalException("Unknown type " + type);
}
return BuiltinOperators.toValue(vType);
}
@@ -514,7 +515,7 @@ public class DefaultFunctions
tName = "Decimal";
break;
default:
throw new RuntimeException("Unknown type " + type);
throw new EvalException("Unknown type " + type);
}
return BuiltinOperators.toValue(tName);
}

+ 3
- 2
src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultNumberFunctions.java View File

@@ -19,6 +19,7 @@ package com.healthmarketscience.jackcess.impl.expr;
import java.math.BigDecimal;

import com.healthmarketscience.jackcess.expr.EvalContext;
import com.healthmarketscience.jackcess.expr.EvalException;
import com.healthmarketscience.jackcess.expr.Function;
import com.healthmarketscience.jackcess.expr.Value;
import static com.healthmarketscience.jackcess.impl.expr.DefaultFunctions.*;
@@ -56,7 +57,7 @@ public class DefaultNumberFunctions
case BIG_DEC:
return BuiltinOperators.toValue(param1.getAsBigDecimal().abs());
default:
throw new RuntimeException("Unexpected type " + mathType);
throw new EvalException("Unexpected type " + mathType);
}
}
});
@@ -160,7 +161,7 @@ public class DefaultNumberFunctions
protected Value eval1(EvalContext ctx, Value param1) {
double dv = param1.getAsDouble();
if(dv < 0.0d) {
throw new IllegalStateException("Invalid value '" + dv + "'");
throw new EvalException("Invalid value '" + dv + "'");
}
return BuiltinOperators.toValue(Math.sqrt(dv));
}

+ 6
- 5
src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java View File

@@ -19,6 +19,7 @@ package com.healthmarketscience.jackcess.impl.expr;
import java.math.BigDecimal;

import com.healthmarketscience.jackcess.expr.EvalContext;
import com.healthmarketscience.jackcess.expr.EvalException;
import com.healthmarketscience.jackcess.expr.Function;
import com.healthmarketscience.jackcess.expr.Value;
import static com.healthmarketscience.jackcess.impl.expr.DefaultFunctions.*;
@@ -42,11 +43,11 @@ public class DefaultTextFunctions
String str = param1.getAsString();
int len = str.length();
if(len == 0) {
throw new IllegalStateException("No characters in string");
throw new EvalException("No characters in string");
}
int lv = str.charAt(0);
if((lv < 0) || (lv > 255)) {
throw new IllegalStateException("Character code '" + lv +
throw new EvalException("Character code '" + lv +
"' out of range ");
}
return BuiltinOperators.toValue(lv);
@@ -59,7 +60,7 @@ public class DefaultTextFunctions
String str = param1.getAsString();
int len = str.length();
if(len == 0) {
throw new IllegalStateException("No characters in string");
throw new EvalException("No characters in string");
}
int lv = str.charAt(0);
return BuiltinOperators.toValue(lv);
@@ -71,7 +72,7 @@ public class DefaultTextFunctions
protected Value eval1(EvalContext ctx, Value param1) {
int lv = param1.getAsLongInt();
if((lv < 0) || (lv > 255)) {
throw new IllegalStateException("Character code '" + lv +
throw new EvalException("Character code '" + lv +
"' out of range ");
}
char[] cs = Character.toChars(lv);
@@ -371,7 +372,7 @@ public class DefaultTextFunctions
return true;
default:
// vbDatabaseCompare -> unsupported
throw new IllegalStateException("Unsupported compare type " + cmpType);
throw new EvalException("Unsupported compare type " + cmpType);
}
}


+ 14
- 14
src/main/java/com/healthmarketscience/jackcess/impl/expr/ExpressionTokenizer.java View File

@@ -18,7 +18,6 @@ package com.healthmarketscience.jackcess.impl.expr;

import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.AbstractMap;
import java.util.ArrayList;
@@ -34,6 +33,7 @@ import java.util.TimeZone;
import static com.healthmarketscience.jackcess.impl.expr.Expressionator.*;
import com.healthmarketscience.jackcess.expr.Value;
import com.healthmarketscience.jackcess.expr.TemporalConfig;
import com.healthmarketscience.jackcess.expr.ParseException;


/**
@@ -152,7 +152,7 @@ class ExpressionTokenizer
tokens.add(new Token(TokenType.OBJ_NAME, parseObjNameString(buf)));
break;
default:
throw new IllegalArgumentException(
throw new ParseException(
"Invalid leading quote character " + c + " " + buf);
}

@@ -258,8 +258,8 @@ class ExpressionTokenizer
}

if(!complete) {
throw new IllegalArgumentException("Missing closing '" + QUOTED_STR_CHAR +
"' for quoted string " + buf);
throw new ParseException("Missing closing '" + QUOTED_STR_CHAR +
"' for quoted string " + buf);
}

return sb.toString();
@@ -282,16 +282,16 @@ class ExpressionTokenizer
break;
} else if((startChar != null) &&
(startChar == c)) {
throw new IllegalArgumentException("Missing closing '" + endChar +
"' for quoted string " + buf);
throw new ParseException("Missing closing '" + endChar +
"' for quoted string " + buf);
}

sb.append(c);
}

if(!complete) {
throw new IllegalArgumentException("Missing closing '" + endChar +
"' for quoted string " + buf);
throw new ParseException("Missing closing '" + endChar +
"' for quoted string " + buf);
}

return sb.toString();
@@ -327,15 +327,15 @@ class ExpressionTokenizer
sdf = (hasAmPm ? buf.getTimeFormat12() : buf.getTimeFormat24());
valType = Value.Type.TIME;
} else {
throw new IllegalArgumentException("Invalid date time literal " + dateStr +
" " + buf);
throw new ParseException("Invalid date time literal " + dateStr +
" " + buf);
}

try {
return new Token(TokenType.LITERAL, sdf.parse(dateStr), dateStr, valType,
sdf);
} catch(ParseException pe) {
throw new IllegalArgumentException(
} catch(java.text.ParseException pe) {
throw new ParseException(
"Invalid date time literal " + dateStr + " " + buf, pe);
}
}
@@ -392,7 +392,7 @@ class ExpressionTokenizer
return new Token(TokenType.LITERAL, num, numStr,
(isFp ? Value.Type.DOUBLE : Value.Type.LONG));
} catch(NumberFormatException ne) {
throw new IllegalArgumentException(
throw new ParseException(
"Invalid number literal " + numStr + " " + buf, ne);
}
@@ -536,7 +536,7 @@ class ExpressionTokenizer
DateFormat df = _ctx.createDateFormat(BASE_DATE_FMT);
baseDate = getDateFormat().format(df.parse(baseDate));
} catch(Exception e) {
throw new IllegalStateException("Could not parse base date", e);
throw new ParseException("Could not parse base date", e);
}
}
_baseDate = baseDate + " ";

+ 26
- 26
src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java View File

@@ -39,6 +39,7 @@ import com.healthmarketscience.jackcess.expr.EvalContext;
import com.healthmarketscience.jackcess.expr.Expression;
import com.healthmarketscience.jackcess.expr.Function;
import com.healthmarketscience.jackcess.expr.TemporalConfig;
import com.healthmarketscience.jackcess.expr.ParseException;
import com.healthmarketscience.jackcess.expr.Value;
import com.healthmarketscience.jackcess.impl.expr.ExpressionTokenizer.Token;
import com.healthmarketscience.jackcess.impl.expr.ExpressionTokenizer.TokenType;
@@ -506,7 +507,7 @@ public class Expressionator
WordType wordType = getWordType(t);
if(wordType == null) {
// shouldn't happen
throw new RuntimeException("Invalid operator " + t);
throw new ParseException("Invalid operator " + t);
}

// this can only be an OP or a COMP (those are the only words that the
@@ -522,7 +523,7 @@ public class Expressionator
break;

default:
throw new RuntimeException("Unexpected OP word type " + wordType);
throw new ParseException("Unexpected OP word type " + wordType);
}
break;
@@ -580,7 +581,7 @@ public class Expressionator
break;

default:
throw new RuntimeException("Unexpected STRING word type "
throw new ParseException("Unexpected STRING word type "
+ wordType);
}
}
@@ -592,7 +593,7 @@ public class Expressionator
break;
default:
throw new RuntimeException("unknown token type " + t);
throw new ParseException("unknown token type " + t);
}

if(singleExpr && buf.hasPendingExpr()) {
@@ -602,7 +603,7 @@ public class Expressionator

Expr expr = buf.takePendingExpr();
if(expr == null) {
throw new IllegalArgumentException("No expression found? " + buf);
throw new ParseException("No expression found? " + buf);
}

return expr;
@@ -641,7 +642,7 @@ public class Expressionator
}

if(atSep || (objNames.size() > 3)) {
throw new IllegalArgumentException("Invalid object reference " + buf);
throw new ParseException("Invalid object reference " + buf);
}

// names are in reverse order
@@ -657,7 +658,7 @@ public class Expressionator
// the only "top-level" delim we expect to find is open paren, and
// there shouldn't be any pending expression
if(!isDelim(firstTok, OPEN_PAREN) || buf.hasPendingExpr()) {
throw new IllegalArgumentException("Unexpected delimiter " +
throw new ParseException("Unexpected delimiter " +
firstTok.getValue() + " " + buf);
}

@@ -683,7 +684,7 @@ public class Expressionator
String funcName = firstTok.getValueStr();
Function func = buf.getFunction(funcName);
if(func == null) {
throw new IllegalArgumentException("Could not find function '" +
throw new ParseException("Could not find function '" +
funcName + "' " + buf);
}
buf.setPendingExpr(new EFunc(func, params));
@@ -738,7 +739,7 @@ public class Expressionator
}
}

throw new IllegalArgumentException("Missing closing '" + CLOSE_PAREN
throw new ParseException("Missing closing '" + CLOSE_PAREN
+ " " + buf);
}

@@ -751,7 +752,7 @@ public class Expressionator
} else if(isEitherOp(t, "-", "+")) {
parseUnaryOpExpression(t, buf);
} else {
throw new IllegalArgumentException(
throw new ParseException(
"Missing left expression for binary operator " + t.getValue() +
" " + buf);
}
@@ -792,7 +793,7 @@ public class Expressionator
// the current field value for the left value
buf.setPendingExpr(THIS_COL_VALUE);
} else {
throw new IllegalArgumentException(
throw new ParseException(
"Missing left expression for comparison operator " +
firstTok.getValue() + " " + buf);
}
@@ -808,7 +809,7 @@ public class Expressionator
private static void parseLogicalOpExpression(Token firstTok, TokBuf buf) {

if(!buf.hasPendingExpr()) {
throw new IllegalArgumentException(
throw new ParseException(
"Missing left expression for logical operator " +
firstTok.getValue() + " " + buf);
}
@@ -836,7 +837,7 @@ public class Expressionator
// the current field value for the left value
buf.setPendingExpr(THIS_COL_VALUE);
} else {
throw new IllegalArgumentException(
throw new ParseException(
"Missing left expression for comparison operator " +
specOp + " " + buf);
}
@@ -855,7 +856,7 @@ public class Expressionator
Token t = buf.next();
if((t.getType() != TokenType.LITERAL) ||
(t.getValueType() != Value.Type.STRING)) {
throw new IllegalArgumentException("Missing Like pattern " + buf);
throw new ParseException("Missing Like pattern " + buf);
}
String patternStr = t.getValueStr();
specOpExpr = new ELikeOp(specOp, expr, patternStr);
@@ -875,7 +876,7 @@ public class Expressionator

if(tmpT == null) {
// ran out of expression?
throw new IllegalArgumentException(
throw new ParseException(
"Missing 'And' for 'Between' expression " + buf);
}

@@ -903,7 +904,7 @@ public class Expressionator
t = buf.next();
}
if(!isDelim(t, OPEN_PAREN)) {
throw new IllegalArgumentException("Malformed In expression " + buf);
throw new ParseException("Malformed In expression " + buf);
}

List<Expr> exprs = findParenExprs(buf, true);
@@ -911,7 +912,7 @@ public class Expressionator
break;

default:
throw new RuntimeException("Unexpected special op " + specOp);
throw new ParseException("Unexpected special op " + specOp);
}

buf.setPendingExpr(specOpExpr);
@@ -950,7 +951,7 @@ public class Expressionator
return SpecOp.NOT;
}

throw new IllegalArgumentException(
throw new ParseException(
"Malformed special operator " + opStr + " " + buf);
}

@@ -963,7 +964,7 @@ public class Expressionator
} else if("null".equalsIgnoreCase(firstTok.getValueStr())) {
constExpr = NULL_VALUE;
} else {
throw new RuntimeException("Unexpected CONST word "
throw new ParseException("Unexpected CONST word "
+ firstTok.getValue());
}
buf.setPendingExpr(constExpr);
@@ -1011,7 +1012,7 @@ public class Expressionator
return op;
}
}
throw new IllegalArgumentException("Unexpected op string " + t.getValueStr());
throw new ParseException("Unexpected op string " + t.getValueStr());
}

private static final class TokBuf
@@ -1097,7 +1098,7 @@ public class Expressionator

public Token next() {
if(!hasNext()) {
throw new IllegalArgumentException(
throw new ParseException(
"Unexpected end of expression " + this);
}
return _tokens.get(_pos++);
@@ -1113,7 +1114,7 @@ public class Expressionator

public void setPendingExpr(Expr expr) {
if(_pendingExpr != null) {
throw new IllegalArgumentException(
throw new ParseException(
"Found multiple expressions with no operator " + this);
}
_pendingExpr = expr.resolveOrderOfOperations();
@@ -1335,7 +1336,7 @@ public class Expressionator
case BIG_DEC:
return new BigDecimalValue((BigDecimal)value);
default:
throw new RuntimeException("unexpected literal type " + valType);
throw new ParseException("unexpected literal type " + valType);
}
}

@@ -1963,7 +1964,7 @@ public class Expressionator
case RECORD_VALIDATOR:
return evalCondition(ctx);
default:
throw new RuntimeException("unexpected expression type " + _type);
throw new ParseException("unexpected expression type " + _type);
}
}

@@ -2008,8 +2009,7 @@ public class Expressionator
case BIG_DEC:
return val.getAsBigDecimal();
default:
throw new IllegalStateException("unexpected result type " +
ctx.getResultType());
throw new IllegalStateException("unexpected result type " + resultType);
}
}


+ 4
- 12
src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java View File

@@ -17,16 +17,8 @@ limitations under the License.
package com.healthmarketscience.jackcess.impl.expr;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.healthmarketscience.jackcess.DatabaseBuilder;
import com.healthmarketscience.jackcess.TestUtil;
import com.healthmarketscience.jackcess.expr.EvalContext;
import com.healthmarketscience.jackcess.expr.Expression;
import com.healthmarketscience.jackcess.expr.Function;
import com.healthmarketscience.jackcess.expr.TemporalConfig;
import com.healthmarketscience.jackcess.expr.Value;

import com.healthmarketscience.jackcess.expr.EvalException;
import junit.framework.TestCase;
import static com.healthmarketscience.jackcess.impl.expr.ExpressionatorTest.eval;

@@ -64,8 +56,8 @@ public class DefaultFunctionsTest extends TestCase

try {
eval("=Str$(Null)");
fail("UnsupportedOperationException should have been thrown");
} catch(UnsupportedOperationException expected) {
fail("EvalException should have been thrown");
} catch(EvalException expected) {
// success
}


Loading…
Cancel
Save