Minor bug fixes.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@46 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
8444136be1
commit
3ea230b11c
@ -30,20 +30,23 @@ public class Get implements Function {
|
||||
start = Math.min(a.length, Math.max(0, start));
|
||||
|
||||
if (to == null) {
|
||||
return a[start];
|
||||
return start < a.length ? a[start] : null;
|
||||
} else {
|
||||
int end = to != null && to instanceof Number ?
|
||||
((Number) to).intValue() : a.length;
|
||||
|
||||
if (end < 0) {
|
||||
end = a.length - end;
|
||||
end = a.length + end;
|
||||
}
|
||||
end = Math.min(a.length, Math.max(start, end));
|
||||
|
||||
Object[] a2 = new Object[end - start];
|
||||
System.arraycopy(a, start, a2, 0, end - start);
|
||||
|
||||
return a2;
|
||||
if (end > start) {
|
||||
Object[] a2 = new Object[end - start];
|
||||
|
||||
System.arraycopy(a, start, a2, 0, end - start);
|
||||
|
||||
return a2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String s = (v instanceof String ? (String) v : v.toString());
|
||||
@ -57,7 +60,7 @@ public class Get implements Function {
|
||||
if (to != null && to instanceof Number) {
|
||||
int end = ((Number) to).intValue();
|
||||
if (end < 0) {
|
||||
end = s.length() - end;
|
||||
end = s.length() + end;
|
||||
}
|
||||
end = Math.min(s.length(), Math.max(start, end));
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class Slice implements Function {
|
||||
start = Math.min(a.length, Math.max(0, start));
|
||||
|
||||
if (end < 0) {
|
||||
end = a.length - end;
|
||||
end = a.length + end;
|
||||
}
|
||||
end = Math.min(a.length, Math.max(start, end));
|
||||
|
||||
@ -46,7 +46,7 @@ public class Slice implements Function {
|
||||
if (to != null && to instanceof Number) {
|
||||
int end = ((Number) to).intValue();
|
||||
if (end < 0) {
|
||||
end = s.length() - end;
|
||||
end = s.length() + end;
|
||||
}
|
||||
end = Math.min(s.length(), Math.max(start, end));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user