[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit WebClient.java,1.24,1.25 WebFrame.java,1.
Brought to you by:
russgold
From: Russell G. <rus...@us...> - 2002-07-30 14:11:17
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv29389/src/com/meterware/httpunit Modified Files: WebClient.java WebFrame.java Log Message: Started refactoring towards link.click Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- WebClient.java 26 Jun 2002 15:48:56 -0000 1.24 +++ WebClient.java 30 Jul 2002 14:11:15 -0000 1.25 @@ -113,7 +113,7 @@ * any listeners or preferences which may have been set. **/ public void clearContents() { - _frameContents = new Hashtable(); + _frameContents = new FrameHolderImpl(); _cookies = new Hashtable(); _headers = new HeaderDictionary(); } @@ -123,14 +123,7 @@ * Returns the name of the currently active frames. **/ public String[] getFrameNames() { - Vector names = new Vector(); - for (Enumeration e = _frameContents.keys(); e.hasMoreElements();) { - names.addElement( e.nextElement() ); - } - - String[] result = new String[ names.size() ]; - names.copyInto( result ); - return result; + return _frameContents.getFrameNames(); } @@ -339,7 +332,7 @@ /** A map of frame names to current contents. **/ - private Hashtable _frameContents = new Hashtable(); + private FrameHolderImpl _frameContents = new FrameHolderImpl(); /** A map of frame names to frames nested within them. **/ @@ -492,6 +485,38 @@ public String getMethod() { return "GET"; } +} + + + +class FrameHolderImpl { + private Hashtable _contents = new Hashtable(); + + void put( String targetName, WebResponse contents ) { + _contents.put( targetName, contents ); + } + + + WebResponse get( String targetName ) { + return (WebResponse) _contents.get( targetName ); + } + + void remove( String targetName ) { + _contents.remove( targetName ); + } + + + public String[] getFrameNames() { + Vector names = new Vector(); + for (Enumeration e = _contents.keys(); e.hasMoreElements();) { + names.addElement( e.nextElement() ); + } + + String[] result = new String[ names.size() ]; + names.copyInto( result ); + return result; + } + } Index: WebFrame.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebFrame.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- WebFrame.java 15 Jul 2002 16:42:44 -0000 1.7 +++ WebFrame.java 30 Jul 2002 14:11:15 -0000 1.8 @@ -51,12 +51,19 @@ } + /** + * Given the qualified name of a frame and the name of a nested frame, returns the qualified name of the nested frame. + */ static String getNestedFrameName( String parentFrameName, final String relativeName ) { if (parentFrameName.equalsIgnoreCase( WebRequest.TOP_FRAME )) return relativeName; return parentFrameName + ':' + relativeName; } + /** + * Returns the qualified name of a target frame. + * + */ static String getTargetFrameName( String sourceFrameName, final String relativeName ) { if (relativeName.equalsIgnoreCase( "_parent" )) return getParentFrameName( sourceFrameName ); if (sourceFrameName.indexOf( ':' ) < 0) return relativeName; |