-
- public abstract Object get(Object key) throws JS.Exn;
- public abstract void put(Object key, Object val) throws JS.Exn;
- public abstract Object[] keys();
-
- public Number coerceToNumber() { throw new Error("you cannot coerce a " + this.getClass().getName() + " into a Number"); }
- public String coerceToString() { throw new Error("you cannot coerce a " + this.getClass().getName() + " into a String"); }
- public boolean coerceToBoolean() { throw new Error("you cannot coerce a " + this.getClass().getName() + " into a Boolean"); }
-
-
- // Inner Classes /////////////////////////////////////////////////////////////////////////
-
- /** A sensible implementation of the abstract methods in the JS class */
- public static class Obj extends JS {
- private Hash entries = new Hash();
- private boolean sealed = false;
- public Obj() { this(false); }
- public Obj(boolean sealed) { this.sealed = sealed; }
- /** a sealed object cannot have its properties modified */
- public void setSeal(boolean sealed) { this.sealed = sealed; }
- public Object get(Object key) { return entries.get(key); }
- public void put(Object key, Object val) { if (!sealed) entries.put(key, val); }
- public Object[] keys() { return(entries.keys()); }
- }
-
- /** An exception which can be thrown and caught by JavaScript code */
- public static class Exn extends RuntimeException {
- private Object js = null;
- public Exn(Object js) { this.js = js; }
- public String toString() { return "JS.Exn: " + js; }
- public String getMessage() { return toString(); }
- public Object getObject() { return js; }
- }
-
- /** The publicly-visible face of JavaScript Array objects */
- public static class Array extends ArrayImpl {
- public Array() { }
- public Array(int size) { super(size); }
- public void setSize(int i) { super.setSize(i); }
- public int length() { return super.length(); }
- public Object elementAt(int i) { return super.elementAt(i); }
- public void addElement(Object o) { super.addElement(o); }
- public void setElementAt(Object o, int i) { super.setElementAt(o, i); }
- public Object get(Object key) { return super._get(key); }
- public void put(Object key, Object val) { super._put(key, val); }
- }
-
- /** Any object which becomes part of the scope chain must support this interface */
- public static class Scope extends ScopeImpl {
- public Scope(Scope parentScope) { this(parentScope, false); }
- public Scope(Scope parentScope, boolean sealed) { super(parentScope, sealed); }
- /** transparent scopes are not returned by THIS */
- public boolean isTransparent() { return super.isTransparent(); }
- public boolean has(Object key) { return super.has(key); }
- public Object get(Object key) { return super._get(key); }
- public void put(Object key, Object val) { super._put(key, val); }
- public void declare(String s) { super.declare(s); }
- }
-
- /** anything that is callable with the () operator */
- public static abstract class Callable extends JS.Obj {
- public abstract Object call(JS.Array args) throws JS.Exn;
- }