Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.meterware.httpunit
Class WebRequestSource  view WebRequestSource download WebRequestSource.java

java.lang.Object
  extended bycom.meterware.httpunit.ParameterHolder
      extended bycom.meterware.httpunit.WebRequestSource
All Implemented Interfaces:
HTMLElement
Direct Known Subclasses:
FixedURLWebRequestSource, WebForm

public abstract class WebRequestSource
extends ParameterHolder
implements HTMLElement

Base class for objects which can be clicked to generate new web requests.


Field Summary
private  WebResponse _baseResponse
          The web response containing this request source.
private  java.net.URL _baseURL
          The URL of the page containing this entity.
private  java.lang.String _defaultTarget
          The name of the frame in which the response containing this request source is rendered.
private  java.lang.String _destination
          The raw destination specified for the request, including anchors and parameters.
private  FrameSelector _frame
           
private  org.w3c.dom.Node _node
          The DOM node representing this entity.
private static java.lang.String PARAM_DELIM
           
 
Constructor Summary
(package private) WebRequestSource(WebResponse response, org.w3c.dom.Node node, java.net.URL baseURL, java.lang.String destination, FrameSelector frame, java.lang.String defaultTarget)
          Contructs a web request source.
 
Method Summary
protected abstract  void addPresetParameter(java.lang.String name, java.lang.String value)
          Records a parameter defined by including it in the destination URL.
private  java.lang.String decode(java.lang.String string)
           
 java.lang.String getAttribute(java.lang.String name)
          Returns the value of the attribute of this element with the specified name.
(package private)  java.lang.String getAttribute(java.lang.String name, java.lang.String defaultValue)
           
protected  WebResponse getBaseResponse()
          Returns the web response containing this request source.
protected  java.net.URL getBaseURL()
           
(package private)  java.lang.String getCharacterSet()
          Returns the character set encoding for the request.
 java.lang.String getClassName()
          Returns the class associated with this request source.
private  WebResponse getCurrentFrame(WebWindow window, FrameSelector pageFrame)
           
protected  WebResponse getCurrentFrameContents()
           
protected  java.lang.String getDestination()
           
 org.w3c.dom.Node getDOMSubtree()
          Returns a copy of the domain object model subtree associated with this entity.
protected abstract  java.lang.String getEmptyParameterValue()
           
 java.lang.String getFragmentIdentifier()
          Returns the fragment identifier for this request source, used to identifier an element within an HTML document.
 FrameSelector getFrame()
          Returns the frame containing this request source.
protected  HTMLPage getHTMLPage()
          Returns the HTMLPage associated with this request source.
 java.lang.String getID()
          Returns the ID associated with this request source.
 java.lang.String getName()
          Returns the name associated with this request source.
protected  org.w3c.dom.Node getNode()
          Returns the actual DOM for this request source, not a copy.
 java.lang.String getPageFrame()
          Deprecated. as of 1.6, use #getFrame
abstract  java.lang.String[] getParameterNames()
          Returns an array containing the names of any parameters to be sent on a request based on this request source.
private  java.lang.String getParametersString()
          Gets all parameters from a URL
abstract  java.lang.String[] getParameterValues(java.lang.String name)
          Returns the values of the named parameter.
(package private)  java.lang.String getRelativePage()
          Returns the URL relative to the current page which will handle the request.
protected  java.lang.String getRelativeURL()
           
abstract  WebRequest getRequest()
          Creates and returns a web request from this request source.
private  java.lang.String getSpecifiedTarget()
           
 java.lang.String getTarget()
          Returns the target for this request source.
 java.lang.String getText()
          Returns the text value of this block.
 java.lang.String getTitle()
          Returns the title associated with this request source.
(package private)  boolean isFileParameter(java.lang.String name)
          Returns true if the specified name is that of a file parameter.
(package private) abstract  boolean isSubmitAsMime()
           
 boolean isSupportedAttribute(java.lang.String name)
          Returns true if this element may have an attribute with the specified name.
protected  void loadDestinationParameters()
          Extracts any parameters specified as part of the destination URL, calling addPresetParameter for each one in the order in which they are found.
(package private) abstract  void recordParameters(ParameterProcessor processor)
          Iterates through the parameters in this holder, recording them in the supplied parameter processor.
(package private) abstract  void recordPredefinedParameters(ParameterProcessor processor)
          Iterates through the fixed, predefined parameters in this holder, recording them in the supplied parameter processor.\ These parameters always go on the URL, no matter what encoding method is used.
(package private) abstract  void removeParameter(java.lang.String name)
          Removes a parameter name from this collection.
(package private)  void selectImageButtonPosition(SubmitButton imageButton, int x, int y)
          Specifies the position at which an image button (if any) was clicked.
protected  void setDestination(java.lang.String destination)
           
(package private) abstract  void setParameter(java.lang.String name, java.lang.String value)
          Sets the value of a parameter in a web request.
(package private) abstract  void setParameter(java.lang.String name, java.lang.String[] values)
          Sets the multiple values of a parameter in a web request.
(package private) abstract  void setParameter(java.lang.String name, UploadFileSpec[] files)
          Sets the multiple values of a file upload parameter in a web request.
(package private) abstract  void setSubmitAsMime(boolean mimeEncoded)
           
protected  void setTargetAttribute(java.lang.String value)
           
private  void stripOneParameter(java.lang.String param)
          Extracts a parameter of the form [=[]].
protected  WebResponse submitRequest(java.lang.String event, WebRequest request)
           
protected  WebResponse submitRequest(WebRequest request)
          Submits a request to the web client from which this request source was originally obtained.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.meterware.httpunit.HTMLElement
getScriptableDelegate
 

Field Detail

_frame

private FrameSelector _frame

PARAM_DELIM

private static final java.lang.String PARAM_DELIM
See Also:
Constant Field Values

_baseResponse

private WebResponse _baseResponse
The web response containing this request source.


_defaultTarget

private java.lang.String _defaultTarget
The name of the frame in which the response containing this request source is rendered.


_baseURL

private java.net.URL _baseURL
The URL of the page containing this entity.


_destination

private java.lang.String _destination
The raw destination specified for the request, including anchors and parameters.


_node

private org.w3c.dom.Node _node
The DOM node representing this entity.

Constructor Detail

WebRequestSource

WebRequestSource(WebResponse response,
                 org.w3c.dom.Node node,
                 java.net.URL baseURL,
                 java.lang.String destination,
                 FrameSelector frame,
                 java.lang.String defaultTarget)
Contructs a web request source.

Method Detail

getID

public java.lang.String getID()
Returns the ID associated with this request source.

Specified by:
getID in interface HTMLElement

getClassName

public java.lang.String getClassName()
Returns the class associated with this request source.

Specified by:
getClassName in interface HTMLElement

getName

public java.lang.String getName()
Returns the name associated with this request source.

Specified by:
getName in interface HTMLElement

getTitle

public java.lang.String getTitle()
Returns the title associated with this request source.

Specified by:
getTitle in interface HTMLElement

getTarget

public java.lang.String getTarget()
Returns the target for this request source.


getPageFrame

public java.lang.String getPageFrame()
Deprecated. as of 1.6, use #getFrame

Returns the name of the frame containing this request source.


getFrame

public FrameSelector getFrame()
Returns the frame containing this request source.


getFragmentIdentifier

public java.lang.String getFragmentIdentifier()
Returns the fragment identifier for this request source, used to identifier an element within an HTML document.


getDOMSubtree

public org.w3c.dom.Node getDOMSubtree()
Returns a copy of the domain object model subtree associated with this entity.


getRequest

public abstract WebRequest getRequest()
Creates and returns a web request from this request source.


getParameterNames

public abstract java.lang.String[] getParameterNames()
Returns an array containing the names of any parameters to be sent on a request based on this request source.

Specified by:
getParameterNames in class ParameterHolder

getParameterValues

public abstract java.lang.String[] getParameterValues(java.lang.String name)
Returns the values of the named parameter.

Specified by:
getParameterValues in class ParameterHolder

getRelativePage

java.lang.String getRelativePage()
Returns the URL relative to the current page which will handle the request.


getRelativeURL

protected java.lang.String getRelativeURL()

getBaseURL

protected java.net.URL getBaseURL()

getDestination

protected java.lang.String getDestination()

setDestination

protected void setDestination(java.lang.String destination)

getNode

protected org.w3c.dom.Node getNode()
Returns the actual DOM for this request source, not a copy.


getHTMLPage

protected HTMLPage getHTMLPage()
                        throws org.xml.sax.SAXException
Returns the HTMLPage associated with this request source.


loadDestinationParameters

protected final void loadDestinationParameters()
Extracts any parameters specified as part of the destination URL, calling addPresetParameter for each one in the order in which they are found.


submitRequest

protected WebResponse submitRequest(java.lang.String event,
                                    WebRequest request)
                             throws java.io.IOException,
                                    org.xml.sax.SAXException

getCurrentFrameContents

protected WebResponse getCurrentFrameContents()

getCurrentFrame

private WebResponse getCurrentFrame(WebWindow window,
                                    FrameSelector pageFrame)

submitRequest

protected final WebResponse submitRequest(WebRequest request)
                                   throws java.io.IOException,
                                          org.xml.sax.SAXException
Submits a request to the web client from which this request source was originally obtained.


getBaseResponse

protected final WebResponse getBaseResponse()
Returns the web response containing this request source.


addPresetParameter

protected abstract void addPresetParameter(java.lang.String name,
                                           java.lang.String value)
Records a parameter defined by including it in the destination URL. The value can be null, if the parameter name was not specified with an equals sign.


getAttribute

public java.lang.String getAttribute(java.lang.String name)
Description copied from interface: HTMLElement
Returns the value of the attribute of this element with the specified name. Returns the empty string if no such attribute exists.

Specified by:
getAttribute in interface HTMLElement

isSupportedAttribute

public boolean isSupportedAttribute(java.lang.String name)
Description copied from interface: HTMLElement
Returns true if this element may have an attribute with the specified name.

Specified by:
isSupportedAttribute in interface HTMLElement

getText

public java.lang.String getText()
Returns the text value of this block.

Specified by:
getText in interface HTMLElement

getAttribute

java.lang.String getAttribute(java.lang.String name,
                              java.lang.String defaultValue)

getSpecifiedTarget

private java.lang.String getSpecifiedTarget()

setTargetAttribute

protected void setTargetAttribute(java.lang.String value)

getParametersString

private java.lang.String getParametersString()
Gets all parameters from a URL


stripOneParameter

private void stripOneParameter(java.lang.String param)
Extracts a parameter of the form [=[]].


decode

private java.lang.String decode(java.lang.String string)

getEmptyParameterValue

protected abstract java.lang.String getEmptyParameterValue()

selectImageButtonPosition

void selectImageButtonPosition(SubmitButton imageButton,
                               int x,
                               int y)
Specifies the position at which an image button (if any) was clicked. This default implementation does nothing.


recordPredefinedParameters

abstract void recordPredefinedParameters(ParameterProcessor processor)
                                  throws java.io.IOException
Iterates through the fixed, predefined parameters in this holder, recording them in the supplied parameter processor.\ These parameters always go on the URL, no matter what encoding method is used.


recordParameters

abstract void recordParameters(ParameterProcessor processor)
                        throws java.io.IOException
Iterates through the parameters in this holder, recording them in the supplied parameter processor.


removeParameter

abstract void removeParameter(java.lang.String name)
Removes a parameter name from this collection.


setParameter

abstract void setParameter(java.lang.String name,
                           java.lang.String value)
Sets the value of a parameter in a web request.


setParameter

abstract void setParameter(java.lang.String name,
                           java.lang.String[] values)
Sets the multiple values of a parameter in a web request.


setParameter

abstract void setParameter(java.lang.String name,
                           UploadFileSpec[] files)
Sets the multiple values of a file upload parameter in a web request.


isFileParameter

boolean isFileParameter(java.lang.String name)
Returns true if the specified name is that of a file parameter. The default implementation returns false.


getCharacterSet

java.lang.String getCharacterSet()
Returns the character set encoding for the request.


isSubmitAsMime

abstract boolean isSubmitAsMime()

setSubmitAsMime

abstract void setSubmitAsMime(boolean mimeEncoded)