[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit ParsedHTML.java,1.35,1.36
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-11-27 15:06:46
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv31599/src/com/meterware/httpunit
Modified Files:
ParsedHTML.java
Log Message:
644642: fixed discarded changes to form parameters made in immediate scripts
Index: ParsedHTML.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ParsedHTML.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- ParsedHTML.java 25 Nov 2002 22:41:07 -0000 1.35
+++ ParsedHTML.java 27 Nov 2002 15:06:41 -0000 1.36
@@ -40,11 +40,19 @@
private String _characterSet;
+ private WebResponse _response;
+
+ private boolean _updateForms;
private WebForm[] _forms;
+
+ private boolean _updateImages;
private WebImage[] _images;
+
+ private boolean _updateLinks;
private WebLink[] _links;
+
+ private boolean _updateApplets;
private WebApplet[] _applets;
- private WebResponse _response;
ParsedHTML( WebResponse response, URL baseURL, String baseTarget, Node rootNode, String characterSet ) {
@@ -60,12 +68,15 @@
* Returns the forms found in the page in the order in which they appear.
**/
public WebForm[] getForms() {
- if (_forms == null) {
+ if (_forms == null || _updateForms) {
NodeList forms = NodeUtils.getElementsByTagName( getRootNode(), "form" );
-
+ WebForm[] oldForms = _forms;
_forms = new WebForm[ forms.getLength() ];
- for (int i = 0; i < _forms.length; i++) {
+
+ if (oldForms != null) System.arraycopy( oldForms, 0, _forms, 0, oldForms.length );
+ for (int i = (oldForms == null ? 0 : oldForms.length); i < _forms.length; i++) {
_forms[i] = new WebForm( _response, _baseURL, _baseTarget, forms.item( i ), _characterSet );
+ _updateForms = false;
}
}
return _forms;
@@ -102,7 +113,7 @@
* Returns the links found in the page in the order in which they appear.
**/
public WebLink[] getLinks() {
- if (_links == null) {
+ if (_links == null || _updateLinks) {
final ArrayList list = new ArrayList();
NodeUtils.processNodes( getRootNode().getChildNodes(), new NodeUtils.NodeAction() {
public boolean processElement( Element element ) {
@@ -113,7 +124,9 @@
public void processTextNodeValue( String value ) {
}
} );
+ if (_links != null) for (int i = 0; i < _links.length; i++) list.set( i, _links[i] );
_links = (WebLink[]) list.toArray( new WebLink[ list.size() ] );
+ _updateLinks = false;
}
return _links;
@@ -189,13 +202,16 @@
* Returns the images found in the page in the order in which they appear.
**/
public WebImage[] getImages() {
- if (_images == null) {
+ if (_images == null || _updateImages) {
NodeList images = NodeUtils.getElementsByTagName( getRootNode(), "img" );
+ WebImage[] oldImages = _images;
_images = new WebImage[ images.getLength() ];
- for (int i = 0; i < _images.length; i++) {
+ if (oldImages != null) System.arraycopy( oldImages, 0, _images, 0, oldImages.length );
+ for (int i = (oldImages == null ? 0 : oldImages.length); i < _images.length; i++) {
_images[i] = new WebImage( _response, this, _baseURL, images.item( i ), _baseTarget );
}
+ _updateImages = false;
}
return _images;
}
@@ -244,13 +260,16 @@
* Returns a proxy for each applet found embedded in this page.
*/
public WebApplet[] getApplets() {
- if (_applets == null) {
+ if (_applets == null || _updateApplets) {
NodeList applets = NodeUtils.getElementsByTagName( getRootNode(), "applet" );
+ WebApplet[] oldApplets = _applets;
_applets = new WebApplet[ applets.getLength() ];
- for (int i = 0; i < _applets.length; i++) {
+ if (oldApplets != null) System.arraycopy( oldApplets, 0, _applets, 0, oldApplets.length );
+ for (int i = (oldApplets == null ? 0 : oldApplets.length); i < _applets.length; i++) {
_applets[i] = new WebApplet( _response, applets.item( i ), _baseTarget );
}
+ _updateApplets = false;
}
return _applets;
}
@@ -342,9 +361,7 @@
throw new IllegalStateException( "The root node has already been defined as " + _rootNode + " and cannot be redefined as " + rootNode );
_rootNode = rootNode;
- _links = null;
- _forms = null;
- _images = null;
+ _updateLinks = _updateForms = _updateImages = _updateApplets = true;
}
|