From 1186a277aef418df5b5a90e3e927a94ac9e76e1f Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 18 Apr 2006 11:08:58 +0000 Subject: [PATCH] * Fix list index checks in list() and prefetch(). --- .../scripting/rhino/ListViewWrapper.java | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/helma/scripting/rhino/ListViewWrapper.java b/src/helma/scripting/rhino/ListViewWrapper.java index 2694b8ba..14fbc06b 100644 --- a/src/helma/scripting/rhino/ListViewWrapper.java +++ b/src/helma/scripting/rhino/ListViewWrapper.java @@ -17,15 +17,12 @@ package helma.scripting.rhino; import helma.objectmodel.INode; import helma.objectmodel.db.Key; -import helma.objectmodel.db.Node; import helma.objectmodel.db.NodeHandle; import helma.objectmodel.db.OrderedSubnodeList; -import helma.objectmodel.db.UpdateableSubnodeList; import helma.objectmodel.db.WrappedNodeManager; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Iterator; import java.util.List; @@ -106,7 +103,6 @@ public class ListViewWrapper extends ScriptableObject implements Wrapper, Script } public Object jsFunction_get(Object idxObj) { - int idx; if (idxObj instanceof Number) return jsFunction_get(((Number) idxObj).intValue()); else // fallback to this View's HopObject's get-function @@ -159,28 +155,21 @@ public class ListViewWrapper extends ScriptableObject implements Wrapper, Script } private void prefetchChildren(int start, int length) { - if (list.size() < 1) - return; if (!(node instanceof helma.objectmodel.db.Node)) return; + checkNode(); + start = Math.max(start, 0); + length = Math.min(list.size() - start, length); if (length < 1) return; - if (start < 0) - return; - if (start >= list.size()) - return; - checkNode(); - int l = Math.min(list.size() - start, length); - if (l < 1) - return; - Key[] keys = new Key[l]; - for (int i = start; i