[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit ParameterHolder.java,1.5,1.6 WebForm.java
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-10-04 15:18:44
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv26798/src/com/meterware/httpunit
Modified Files:
ParameterHolder.java WebForm.java WebLink.java
WebRequestSource.java
Log Message:
Refactor to simplify adding attribute support
Index: ParameterHolder.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParameterHolder.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ParameterHolder.java 4 Feb 2002 22:33:55 -0000 1.5
+++ ParameterHolder.java 4 Oct 2002 15:18:37 -0000 1.6
@@ -27,7 +27,8 @@
/**
- * This interface is implemented by classes which hold parameters for web requests.
+ * This abstract class is extended by classes which hold parameters for web requests. Note that it is an abstract class
+ * rather than an interface in order to keep its methods package-local.
*
* @author <a href="mailto:rus...@ac...">Russell Gold</a>
**/
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- WebForm.java 3 Oct 2002 12:35:18 -0000 1.66
+++ WebForm.java 4 Oct 2002 15:18:37 -0000 1.67
@@ -57,7 +57,7 @@
* Submits this form using the web client from which it was originally obtained.
**/
WebResponse submit( SubmitButton button ) throws IOException, SAXException {
- String event = NodeUtils.getNodeAttribute( getNode(), "onsubmit" );
+ String event = getAttribute( "onsubmit" );
if (event.length() == 0 || getScriptableObject().doEvent( event )) return submitRequest( getRequest( button ) );
return getBaseResponse();
}
@@ -67,7 +67,7 @@
* Returns the method defined for this form.
**/
public String getMethod() {
- return NodeUtils.getNodeAttribute( getNode(), "method", "GET" );
+ return getAttribute( "method", "GET" );
}
@@ -322,7 +322,7 @@
* Returns true if this form is to be submitted using mime encoding (the default is URL encoding).
**/
public boolean isSubmitAsMime() {
- return "multipart/form-data".equalsIgnoreCase( NodeUtils.getNodeAttribute( getNode(), "enctype" ) );
+ return "multipart/form-data".equalsIgnoreCase( getAttribute( "enctype" ) );
}
@@ -330,7 +330,7 @@
* Resets all parameters to their initial values.
*/
public void reset() {
- String event = NodeUtils.getNodeAttribute( getNode(), "onreset" );
+ String event = getAttribute( "onreset" );
if (event.length() == 0 || getScriptableObject().doEvent( event )) resetControls();
}
Index: WebLink.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- WebLink.java 2 Oct 2002 16:20:45 -0000 1.30
+++ WebLink.java 4 Oct 2002 15:18:37 -0000 1.31
@@ -67,7 +67,7 @@
**/
public String asText() {
if (getNode().getNodeName().equals( "area" )) {
- return NodeUtils.getNodeAttribute( getNode(), "alt" );
+ return getAttribute( "alt" );
} else if (!getNode().hasChildNodes()) {
return "";
} else {
@@ -80,7 +80,7 @@
* Submits a request as though the user had clicked on this link. Will also fire the 'onClick' event if defined.
**/
public WebResponse click() throws IOException, SAXException {
- String event = NodeUtils.getNodeAttribute( getNode(), "onclick" );
+ String event = getAttribute( "onclick" );
if (event.length() == 0 || getScriptableObject().doEvent( event )) return submitRequest();
return getBaseResponse();
}
@@ -90,7 +90,7 @@
* Simulates moving the mouse over the link. Will fire the 'onMouseOver' event if defined.
**/
public void mouseOver() {
- String event = NodeUtils.getNodeAttribute( getNode(), "onmouseover" );
+ String event = getAttribute( "onmouseover" );
if (event.length() > 0) getScriptableObject().doEvent( event );
}
Index: WebRequestSource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- WebRequestSource.java 4 Oct 2002 00:40:28 -0000 1.16
+++ WebRequestSource.java 4 Oct 2002 15:18:37 -0000 1.17
@@ -37,7 +37,7 @@
* Returns the ID associated with this request source.
**/
public String getID() {
- return NodeUtils.getNodeAttribute( _node, "id" );
+ return getAttribute( "id" );
}
@@ -45,7 +45,7 @@
* Returns the name associated with this request source.
**/
public String getName() {
- return NodeUtils.getNodeAttribute( _node, "name" );
+ return getAttribute( "name" );
}
@@ -216,6 +216,16 @@
protected void addPresetParameter( String name, String value );
+ String getAttribute( final String name ) {
+ return NodeUtils.getNodeAttribute( _node, name );
+ }
+
+
+ String getAttribute( final String name, String defaultValue ) {
+ return NodeUtils.getNodeAttribute( _node, name, defaultValue );
+ }
+
+
//----------------------------- private members -----------------------------------------------
@@ -236,8 +246,9 @@
/** The DOM node representing this entity. **/
private Node _node;
+
private String getSpecifiedTarget() {
- return NodeUtils.getNodeAttribute( _node, "target" );
+ return getAttribute( "target" );
}
|