/** Returns the object represented by the given path,
* ignoring the current shell path context.*/
- public Object getFromPath(Object[] path) throws NoSuchPathException, JSExn {
+ public Object getFromPath(Object[] path) throws BadPathException, JSExn {
if (path.length == 0) return root;
if (root instanceof JSRemote) {
JS cur = root;
for (int i=0; i < path.length - 1; i++) {
Object o = cur.get(path[i]);
- if (o == null || !(o instanceof JS)) throw new Shell.NoSuchPathException();
+ if (o == null || !(o instanceof JS)) throw new Shell.BadPathException();
cur = (JS)o;
}
return cur.get(path[path.length - 1]);
}
}
+ public void transaction(JS t) {
+ if (root instanceof JSRemote) {
+ ((JSRemote)root).transaction(
+ JS.cloneWithNewParentScope(t, new JSScope(null)));
+ } else {
+ // FIXME JS.eval(JS.cloneWithNewParentScope(t, root));
+ }
+ }
+
/** Set the current path of the shell, modifiying the result of getScope(). */
- public void setPath(Object[] s) throws NoSuchPathException {
+ public void setPath(Object[] s) throws BadPathException {
JS cur = root;
if (s == null) s = new Object[0];
for (int i=0; i < s.length; i++) {
Object o;
- try { o = cur.get(s[i]); } catch (JSExn e) { throw new NoSuchPathException(); }
- if (o == null || !(o instanceof JS)) throw new NoSuchPathException();
+ try { o = cur.get(s[i]); } catch (JSExn e) { throw new BadPathException(); }
+ if (o == null || !(o instanceof JS)) throw new BadPathException();
cur = (JS)o;
}
scope = cur;
}
}
- public static class NoSuchPathException extends Exception {}
+ public static class BadPathException extends Exception {
+ public BadPathException() {}
+ public BadPathException(String msg) { super(msg); }
+ }
}