From 42e2552fbebac9bef0b0461906129aac622cf92a Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 2 Dec 2003 16:42:13 +0000 Subject: [PATCH] Implement HopObject.list(start, length) as proposed by Tobi in . This is similar to HopObject.list(), except the array it returns only contains the child objects in the range specified by the start and length arguments. This also does a prefetchChildren() on the specified range to optimize database access. --- src/helma/scripting/rhino/HopObject.java | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/helma/scripting/rhino/HopObject.java b/src/helma/scripting/rhino/HopObject.java index d1a11cc8..3dfcd542 100644 --- a/src/helma/scripting/rhino/HopObject.java +++ b/src/helma/scripting/rhino/HopObject.java @@ -452,6 +452,31 @@ public class HopObject extends ScriptableObject implements Wrapper { return Context.getCurrentContext().newArray(core.global, a.toArray()); } + /** + * Return a JS array of child objects with the given start and length. + * + * @return A JavaScript Array containing the specified child objexts + */ + public Scriptable jsFunction_list(int start, int length) { + if (start < 0 || length < 0) { + throw new EvaluatorException("Arguments must not be negative in HopObject.list(start, length)"); + } + + checkNode(); + + jsFunction_prefetchChildren(start, length); + ArrayList a = new ArrayList(); + + for (int i=start; i