aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctions.java4
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultTextFunctions.java6
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);
}
});