diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2018-07-17 03:48:14 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2018-07-17 03:48:14 +0000 |
commit | 18a4998e71e239bba1712109f456dbea80067867 (patch) | |
tree | db0471aac0f623f049d640ce00e9c31ee166bafe /src/main/java | |
parent | 37338c5a25a74244ac95cbcc1f1ab4e1e5b649d1 (diff) | |
download | jackcess-18a4998e71e239bba1712109f456dbea80067867.tar.gz jackcess-18a4998e71e239bba1712109f456dbea80067867.zip |
test more functions
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1182 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java | 4 | ||||
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java | 6 |
2 files changed, 6 insertions, 4 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 b691d64..f77e0a3 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java @@ -90,13 +90,13 @@ public class DefaultFunctions } } - protected IllegalStateException invalidFunctionCall( + protected EvalException invalidFunctionCall( Throwable t, Value[] params) { String paramStr = Arrays.toString(params); String msg = "Invalid function call {" + _name + "(" + paramStr.substring(1, paramStr.length() - 1) + ")}"; - return new IllegalStateException(msg, t); + return new EvalException(msg, t); } @Override diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java index b419f70..7831d6e 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java @@ -244,8 +244,8 @@ public class DefaultTextFunctions String str = param1.getAsString(); int strLen = str.length(); // 1 based offsets - int start = Math.max(strLen, params[1].getAsLongInt() - 1); - int len = Math.max( + int start = Math.min(strLen, params[1].getAsLongInt() - 1); + int len = Math.min( ((params.length > 2) ? params[2].getAsLongInt() : strLen), (strLen - start)); return BuiltinOperators.toValue(str.substring(start, start + len)); @@ -308,6 +308,8 @@ public class DefaultTextFunctions } int cmp = (ignoreCase ? s1.compareToIgnoreCase(s2) : s1.compareTo(s2)); + // stupid java doesn't return 1, -1, 0... + cmp = ((cmp < 0) ? -1 : ((cmp > 0) ? 1 : 0)); return BuiltinOperators.toValue(cmp); } }); |