Fixed error in substring range check.

git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@487923 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Marc Prud'hommeaux 2006-12-17 00:31:48 +00:00
parent 264356a23f
commit d98ca1d91d
1 changed files with 3 additions and 3 deletions

View File

@ -51,9 +51,9 @@ class Substring
if (arg instanceof Object[]) {
Object[] args = (Object[]) arg;
int start = ((Number) args[0]).intValue();
int end = Math.min(((Number) args[1]).intValue(),
str.toString().length() - start + 1);
return str.toString().substring(start, end);
int end = ((Number) args[1]).intValue();
String string = str == null ? "" : str.toString();
return string.substring(start, Math.min(end, string.length()));
}
return str.toString().substring(((Number) arg).intValue());
}