[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit/javascript JavaScript.java,1.32,1.33
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-10-22 20:15:40
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv7196/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
Slight cleanup, added jars to distribution
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- JavaScript.java 13 Oct 2002 23:53:48 -0000 1.32
+++ JavaScript.java 22 Oct 2002 20:15:34 -0000 1.33
@@ -24,7 +24,6 @@
import com.meterware.httpunit.scripting.*;
import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
import java.util.ArrayList;
import java.io.IOException;
@@ -33,6 +32,7 @@
/**
+ * This class is the Rhino-compatible implementation of the JavaScript DOM objects.
*
* @author <a href="mailto:rus...@ht...">Russell Gold</a>
**/
@@ -206,24 +206,13 @@
private Object convertIfNeeded( final Object property ) {
if (property == null) return NOT_FOUND;
- try {
- if (property instanceof ScriptableDelegate[]) return toScriptable( (ScriptableDelegate[]) property );
- if (!(property instanceof ScriptableDelegate)) return property;
- return toScriptable( (ScriptableDelegate) property );
- } catch (PropertyException e) {
- throw new RuntimeException( e.toString() );
- } catch (NotAFunctionException e) {
- throw new RuntimeException( e.toString() );
- } catch (JavaScriptException e) {
- throw new RuntimeException( e.toString() );
- } catch (SAXException e) {
- throw new RuntimeException( e.toString() );
- }
+ if (property instanceof ScriptableDelegate[]) return toScriptable( (ScriptableDelegate[]) property );
+ if (!(property instanceof ScriptableDelegate)) return property;
+ return toScriptable( (ScriptableDelegate) property );
}
- private Object toScriptable( ScriptableDelegate[] list )
- throws PropertyException, NotAFunctionException, JavaScriptException, SAXException {
+ private Object toScriptable( ScriptableDelegate[] list ) {
Object[] delegates = new Object[ list.length ];
for (int i = 0; i < delegates.length; i++) {
delegates[i] = toScriptable( list[i] );
@@ -446,7 +435,7 @@
}
- private void initializeImages() throws SAXException {
+ private void initializeImages() {
WebImage.Scriptable scriptables[] = getDelegate().getImages();
Image[] images = new Image[ scriptables.length ];
for (int i = 0; i < images.length; i++) {
@@ -457,7 +446,7 @@
}
- private void initializeLinks() throws SAXException {
+ private void initializeLinks() {
WebLink.Scriptable scriptables[] = getDelegate().getLinks();
Link[] links = new Link[ scriptables.length ];
for (int i = 0; i < links.length; i++) {
@@ -468,7 +457,7 @@
}
- private void initializeForms() throws SAXException {
+ private void initializeForms() {
WebForm.Scriptable scriptables[] = getDelegate().getForms();
Form[] forms = new Form[ scriptables.length ];
for (int i = 0; i < forms.length; i++) {
@@ -681,7 +670,10 @@
}
- public Scriptable jsGet_elements() {
+ public Scriptable jsGet_elements() throws PropertyException, NotAFunctionException, JavaScriptException {
+ if (_controls == null) {
+ initializeControls();
+ }
return _controls;
}
@@ -696,14 +688,7 @@
}
- void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable )
- throws JavaScriptException, NotAFunctionException, PropertyException, SAXException {
- super.initialize( parent, scriptable );
- initializeControls();
- }
-
-
- private void initializeControls() throws PropertyException, NotAFunctionException, JavaScriptException, SAXException {
+ 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++) {
|