public Object get( String name, Scriptable scriptable ) { for (int i = 0; i < _contents.length; i++) { JavaScriptEngine content = _contents[ i ]; if (name.equalsIgnoreCase( content.getID() )) return content; } for (int i = 0; i < _contents.length; i++) { JavaScriptEngine content = _contents[ i ]; if (name.equalsIgnoreCase( content.getName() )) return content; } return super.get( name, scriptable ); }
public ScriptingEngine newScriptingEngine( ScriptableDelegate child ) { try { return (ScriptingEngine) toScriptable( child ); } catch (Exception e) { HttpUnitUtils.handleException(e); throw new RuntimeException( e.toString() ); } }
/** * Converts a scriptable delegate obtained from a subobject into the appropriate Rhino-compatible Scriptable. **/ final Object toScriptable( ScriptableDelegate delegate ) { if (delegate == null) { return NOT_FOUND; } else if (delegate.getScriptEngine() instanceof Scriptable) { return (Scriptable) delegate.getScriptEngine(); } else { try { JavaScriptEngine element = (JavaScriptEngine) Context.getCurrentContext().newObject( this, getScriptableClassName( delegate ) ); element.initialize( this, delegate ); return element; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RhinoException( e ); } } }
/** * Converts a scriptable delegate obtained from a subobject into the appropriate Rhino-compatible Scriptable. **/ final Object toScriptable( ScriptableDelegate delegate ) { if (delegate == null) { return NOT_FOUND; } else if (delegate.getScriptEngine() instanceof Scriptable) { return (Scriptable) delegate.getScriptEngine(); } else { try { JavaScriptEngine element = (JavaScriptEngine) Context.getCurrentContext().newObject( this, getScriptableClassName( delegate ) ); element.initialize( this, delegate ); return element; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RhinoException( e ); } } }
/** * Converts a scriptable delegate obtained from a subobject into the appropriate Rhino-compatible Scriptable. **/ final Object toScriptable( ScriptableDelegate delegate ) { if (delegate == null) { return NOT_FOUND; } else if (delegate.getScriptEngine() instanceof Scriptable) { return (Scriptable) delegate.getScriptEngine(); } else { try { JavaScriptEngine element = (JavaScriptEngine) Context.getCurrentContext().newObject( this, getScriptableClassName( delegate ) ); element.initialize( this, delegate ); return element; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RhinoException( e ); } } }
/** * initialize JavaScript for the given ScriptEngine * @parent - the Script Engine to use * @scriptable - the scriptable object to do the initialization for */ void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable ) throws JavaScriptException, NotAFunctionException, PropertyException, SAXException { super.initialize( parent, scriptable ); _location = (Location) Context.getCurrentContext().newObject( this, "Location" ); _location.initialize(this, ((WebResponse.Scriptable) scriptable).getURL() ); _navigator = (Navigator) Context.getCurrentContext().newObject( this, "Navigator" ); _navigator.setClientProperties( getDelegate().getClientProperties() ); _screen = (Screen) Context.getCurrentContext().newObject( this, "Screen" ); _screen.setClientProperties( getDelegate().getClientProperties() ); }
public String toString() { return (_scriptable == null ? "prototype " : "") + getClassName(); }
public Object jsFunction_getElementsByTagName( String name ) throws SAXException { return toElementArray( getDelegate().getElementsByTagName( name ) ); }
public String toString() { return (_scriptable == null ? "prototype " : "") + getClassName(); }
/** * initialize JavaScript for the given ScriptEngine * @parent - the Script Engine to use * @scriptable - the scriptable object to do the initialization for */ void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable ) throws JavaScriptException, NotAFunctionException, PropertyException, SAXException { super.initialize( parent, scriptable ); _location = (Location) Context.getCurrentContext().newObject( this, "Location" ); _location.initialize(this, ((WebResponse.Scriptable) scriptable).getURL() ); _navigator = (Navigator) Context.getCurrentContext().newObject( this, "Navigator" ); _navigator.setClientProperties( getDelegate().getClientProperties() ); _screen = (Screen) Context.getCurrentContext().newObject( this, "Screen" ); _screen.setClientProperties( getDelegate().getClientProperties() ); }
/** * initialize JavaScript for the given ScriptEngine * @parent - the Script Engine to use * @scriptable - the scriptable object to do the initialization for */ void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable ) throws JavaScriptException, NotAFunctionException, PropertyException, SAXException { super.initialize( parent, scriptable ); _location = (Location) Context.getCurrentContext().newObject( this, "Location" ); _location.initialize(this, ((WebResponse.Scriptable) scriptable).getURL() ); _navigator = (Navigator) Context.getCurrentContext().newObject( this, "Navigator" ); _navigator.setClientProperties( getDelegate().getClientProperties() ); _screen = (Screen) Context.getCurrentContext().newObject( this, "Screen" ); _screen.setClientProperties( getDelegate().getClientProperties() ); }
public Object jsFunction_getElementById( String id ) { ScriptableDelegate elementWithID = getDelegate().getElementWithID( id ); return elementWithID == null ? null : toScriptable( elementWithID ); }
public Object jsFunction_getElementsByTagName( String name ) { return toElementArray( getDelegate().getElementsByTagName( name ) ); }
public Object jsFunction_getElementsByName( String name ) { return toElementArray( getDelegate().getElementsByName( name ) ); }
public Scriptable jsGet_forms() throws SAXException { if (_forms == null) _forms = toElementArray( getDelegate().getForms() ); return _forms; }
public Scriptable jsGet_images() throws SAXException{ if (_images == null) _images = toElementArray( getDelegate().getImages() ); return _images; }
private void initializeControls() throws PropertyException, NotAFunctionException, JavaScriptException { ScriptableDelegate scriptables[] = getDelegate().getElementDelegates(); Control[] controls = new Control[ scriptables.length ]; for (int i = 0; i < controls.length; i++) { controls[ i ] = (Control) toScriptable( scriptables[ i ] ); } _controls = (ElementArray) Context.getCurrentContext().newObject( this, "ElementArray" ); _controls.initialize( controls ); }
private Object toScriptable( ScriptableDelegate[] list ) { Object[] delegates = new Object[ list.length ]; for (int i = 0; i < delegates.length; i++) { delegates[i] = toScriptable( list[i] ); } return Context.getCurrentContext().newArray( this, delegates ); }
private Object convertIfNeeded( final Object property ) { if (property == null) return NOT_FOUND; if (property instanceof ScriptableDelegate[]) return toScriptable( (ScriptableDelegate[]) property ); if (!(property instanceof ScriptableDelegate)) return property; return toScriptable( (ScriptableDelegate) property ); }
void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable ) throws JavaScriptException, NotAFunctionException, PropertyException, SAXException { super.initialize( parent, scriptable ); _document = (Document) parent; _style = (Style) Context.getCurrentContext().newObject( this, "Style" ); }