You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Paul Hammant <Pa...@yahoo.com> on 2001/11/28 22:33:08 UTC
[DB] JavaScript advice
For the "basic" parser were using JavaScript for row iteration. It's a
cheap way of handling nested where clauses.
I am having trouble with looping in Javascript
Here is our problem script :
var more = iterator.hasNext();
if (more) {
do {
var row = iterator.next();
if ( testHelper.test(row) ) {
callBack.matches(row, true);
} else {
callBack.matches(row, false);
}
} while(iterator.hasNext())
}
Context/Assertions:
1) iterator, callBack and testHelper are Java objects are passed into
the Javascript context.
2) testHelper.test() returns boolean true (for the sake of argument)
3) all else is Javascript.
Basically when we morph to ....
if ( testHelper.test(row) ) {
callBack.matches(row, true);
} else {
callBack.matches(row, false);
}
....and do the iteration in Java (outside the JavaScript) it all works
fine. But given the overhead of instantiation of the Rhino engine for
each test, we'd prefer to do the former script.
Anyone have any ideas as to why Rhino barfs with a non-specific exception?
Regards,
- Paul H
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>