com.meterware.httpunit
Class BlockElement

java.lang.Object
  extended bycom.meterware.httpunit.ParsedHTML
      extended bycom.meterware.httpunit.BlockElement
All Implemented Interfaces:
HTMLElement, HTMLSegment
Direct Known Subclasses:
TableCell, TextBlock

public abstract class BlockElement
extends com.meterware.httpunit.ParsedHTML
implements HTMLSegment, HTMLElement

Represents a block-level element such as a paragraph or table cell, which can contain other elements.

Since:
1.6
Author:
Russell Gold

Constructor Summary
protected BlockElement(WebResponse response, FrameSelector frame, java.net.URL baseURL, java.lang.String baseTarget, org.w3c.dom.Node rootNode, java.lang.String characterSet)
           
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 WebApplet[] getApplets()
          Returns a proxy for each applet found embedded in this page.
 java.lang.String getAttribute(java.lang.String name)
          Returns the value of the attribute of this element with the specified name.
protected  int getAttributeValue(org.w3c.dom.Node node, java.lang.String attributeName, int defaultValue)
           
 java.lang.String getClassName()
          Returns the class attribute associated with this element.
 org.w3c.dom.Node getDOM()
          Returns a copy of the domain object model associated with this HTML segment.
 java.lang.String[] getElementNames()
          Returns a list of HTML element names contained in this HTML section.
 HTMLElement[] getElementsWithAttribute(java.lang.String name, java.lang.String value)
          Returns the HTML elements with an attribute with the specified name and value.
 HTMLElement[] getElementsWithName(java.lang.String name)
          Returns the HTML elements with the specified name.
 HTMLElement getElementWithID(java.lang.String id)
          Returns the HTMLElement with the specified ID.
 WebForm getFirstMatchingForm(HTMLElementPredicate predicate, java.lang.Object criteria)
          Returns the first link found in the page matching the specified criteria.
 WebLink getFirstMatchingLink(HTMLElementPredicate predicate, java.lang.Object criteria)
          Returns the first link found in the page matching the specified criteria.
 WebTable getFirstMatchingTable(HTMLElementPredicate predicate, java.lang.Object criteria)
          Returns the first table in the response which matches the specified predicate and value.
 TextBlock getFirstMatchingTextBlock(HTMLElementPredicate predicate, java.lang.Object criteria)
          Returns the first text block found in the page which matches the specified predicate and value.
 WebForm[] getForms()
          Returns the forms found in the page in the order in which they appear.
 WebForm getFormWithID(java.lang.String id)
          Returns the form found in the page with the specified ID.
 WebForm getFormWithName(java.lang.String name)
          Returns the form found in the page with the specified name.
 com.meterware.httpunit.WebFrame[] getFrames()
          Returns the frames found in the page in the order in which they appear.
 java.lang.String getID()
          Returns the ID associated with this element.
 WebImage[] getImages()
          Returns the images found in the page in the order in which they appear.
 WebImage getImageWithAltText(java.lang.String altText)
          Returns the first image found in the page with the specified alt attribute.
 WebImage getImageWithName(java.lang.String name)
          Returns the image found in the page with the specified name.
 WebImage getImageWithSource(java.lang.String source)
          Returns the first image found in the page with the specified src attribute.
 WebLink[] getLinks()
          Returns the links found in the page in the order in which they appear.
 WebLink getLinkWith(java.lang.String text)
          Returns the first link which contains the specified text.
 WebLink getLinkWithID(java.lang.String id)
          Returns the link found in the page with the specified ID.
 WebLink getLinkWithImageText(java.lang.String text)
          Returns the link which contains the first image with the specified text as its 'alt' attribute.
 WebLink getLinkWithName(java.lang.String name)
          Returns the link found in the page with the specified name.
 WebForm[] getMatchingForms(HTMLElementPredicate predicate, java.lang.Object criteria)
          Returns all links found in the page matching the specified criteria.
 WebLink[] getMatchingLinks(HTMLElementPredicate predicate, java.lang.Object criteria)
          Returns all links found in the page matching the specified criteria.
 WebTable[] getMatchingTables(HTMLElementPredicate predicate, java.lang.Object criteria)
          Returns the tables in the response which match the specified predicate and value.
 java.lang.String getName()
          Returns the name associated with this element.
 TextBlock getNextTextBlock(TextBlock block)
           
 ScriptableDelegate getScriptableDelegate()
          Returns the delegate which supports scripting this element.
 WebTable[] getTables()
          Returns the top-level tables found in the page in the order in which they appear.
 WebTable getTableStartingWith(java.lang.String text)
          Returns the first table in the response which has the specified text as the full text of its first non-blank row and non-blank column.
 WebTable getTableStartingWithPrefix(java.lang.String text)
          Returns the first table in the response which has the specified text as a prefix of the text in its first non-blank row and non-blank column.
 WebTable getTableWithID(java.lang.String ID)
          Returns the first table in the response which has the specified text as its ID attribute.
 WebTable getTableWithSummary(java.lang.String summary)
          Returns the first table in the response which has the specified text as its summary attribute.
 java.lang.String getTagName()
          Returns the tag for this block.
 java.lang.String getText()
          Returns the text value of this block.
 TextBlock[] getTextBlocks()
          Returns the top-level block elements found in the page in the order in which they appear.
 java.lang.String getTitle()
          Returns the title associated with this element.
 int hashCode()
           
 boolean isSupportedAttribute(java.lang.String name)
          Returns true if this element may have an attribute with the specified name.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.meterware.httpunit.HTMLSegment
getApplets, getElementNames, getElementsWithAttribute, getElementsWithName, getElementWithID, getFirstMatchingForm, getFirstMatchingLink, getFirstMatchingTable, getForms, getFormWithID, getFormWithName, getImages, getImageWithAltText, getImageWithName, getImageWithSource, getLinks, getLinkWith, getLinkWithImageText, getMatchingForms, getMatchingLinks, getMatchingTables, getTables, getTableStartingWith, getTableStartingWithPrefix, getTableWithID, getTableWithSummary, getTextBlocks
 

Constructor Detail

BlockElement

protected BlockElement(WebResponse response,
                       FrameSelector frame,
                       java.net.URL baseURL,
                       java.lang.String baseTarget,
                       org.w3c.dom.Node rootNode,
                       java.lang.String characterSet)
Method Detail

getText

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

Specified by:
getText in interface HTMLElement

getTagName

public java.lang.String getTagName()
Returns the tag for this block.

Specified by:
getTagName in interface HTMLElement

getDOM

public org.w3c.dom.Node getDOM()
Returns a copy of the domain object model associated with this HTML segment.


getID

public java.lang.String getID()
Returns the ID associated with this element. IDs are unique throughout the HTML document.

Specified by:
getID in interface HTMLElement

getClassName

public java.lang.String getClassName()
Returns the class attribute associated with this element.

Specified by:
getClassName in interface HTMLElement

getName

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

Specified by:
getName in interface HTMLElement

getTitle

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

Specified by:
getTitle in interface HTMLElement

getScriptableDelegate

public ScriptableDelegate getScriptableDelegate()
Returns the delegate which supports scripting this element.

Specified by:
getScriptableDelegate in interface HTMLElement

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)
Returns true if this element may have an attribute with the specified name.

Specified by:
isSupportedAttribute in interface HTMLElement

equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()

getAttributeValue

protected int getAttributeValue(org.w3c.dom.Node node,
                                java.lang.String attributeName,
                                int defaultValue)

getForms

public WebForm[] getForms()
Returns the forms found in the page in the order in which they appear.


getLinks

public WebLink[] getLinks()
Returns the links found in the page in the order in which they appear.


getApplets

public WebApplet[] getApplets()
Returns a proxy for each applet found embedded in this page.


getImages

public WebImage[] getImages()
Returns the images found in the page in the order in which they appear.


getTextBlocks

public TextBlock[] getTextBlocks()
Returns the top-level block elements found in the page in the order in which they appear.


getFirstMatchingTextBlock

public TextBlock getFirstMatchingTextBlock(HTMLElementPredicate predicate,
                                           java.lang.Object criteria)
Returns the first text block found in the page which matches the specified predicate and value.


getNextTextBlock

public TextBlock getNextTextBlock(TextBlock block)

getTables

public WebTable[] getTables()
Returns the top-level tables found in the page in the order in which they appear.


getElementWithID

public HTMLElement getElementWithID(java.lang.String id)
Returns the HTMLElement with the specified ID.


getElementsWithName

public HTMLElement[] getElementsWithName(java.lang.String name)
Returns the HTML elements with the specified name.


getElementsWithAttribute

public HTMLElement[] getElementsWithAttribute(java.lang.String name,
                                              java.lang.String value)
Returns the HTML elements with an attribute with the specified name and value.


getElementNames

public java.lang.String[] getElementNames()
Returns a list of HTML element names contained in this HTML section.


getFormWithID

public WebForm getFormWithID(java.lang.String id)
Returns the form found in the page with the specified ID.


getLinkWithID

public WebLink getLinkWithID(java.lang.String id)
Returns the link found in the page with the specified ID.


getFirstMatchingForm

public WebForm getFirstMatchingForm(HTMLElementPredicate predicate,
                                    java.lang.Object criteria)
Returns the first link found in the page matching the specified criteria.


getMatchingForms

public WebForm[] getMatchingForms(HTMLElementPredicate predicate,
                                  java.lang.Object criteria)
Returns all links found in the page matching the specified criteria.


getFormWithName

public WebForm getFormWithName(java.lang.String name)
Returns the form found in the page with the specified name.


getLinkWith

public WebLink getLinkWith(java.lang.String text)
Returns the first link which contains the specified text.


getLinkWithImageText

public WebLink getLinkWithImageText(java.lang.String text)
Returns the link which contains the first image with the specified text as its 'alt' attribute.


getLinkWithName

public WebLink getLinkWithName(java.lang.String name)
Returns the link found in the page with the specified name.


getFirstMatchingLink

public WebLink getFirstMatchingLink(HTMLElementPredicate predicate,
                                    java.lang.Object criteria)
Returns the first link found in the page matching the specified criteria.


getMatchingLinks

public WebLink[] getMatchingLinks(HTMLElementPredicate predicate,
                                  java.lang.Object criteria)
Returns all links found in the page matching the specified criteria.


getImageWithName

public WebImage getImageWithName(java.lang.String name)
Returns the image found in the page with the specified name.


getImageWithSource

public WebImage getImageWithSource(java.lang.String source)
Returns the first image found in the page with the specified src attribute.


getImageWithAltText

public WebImage getImageWithAltText(java.lang.String altText)
Returns the first image found in the page with the specified alt attribute.


getFirstMatchingTable

public WebTable getFirstMatchingTable(HTMLElementPredicate predicate,
                                      java.lang.Object criteria)
Returns the first table in the response which matches the specified predicate and value. Will recurse into any nested tables, as needed.

Returns:
the selected table, or null if none is found

getMatchingTables

public WebTable[] getMatchingTables(HTMLElementPredicate predicate,
                                    java.lang.Object criteria)
Returns the tables in the response which match the specified predicate and value. Will recurse into any nested tables, as needed.

Returns:
the selected tables, or null if none are found

getTableStartingWith

public WebTable getTableStartingWith(java.lang.String text)
Returns the first table in the response which has the specified text as the full text of its first non-blank row and non-blank column. Will recurse into any nested tables, as needed.

Returns:
the selected table, or null if none is found

getTableStartingWithPrefix

public WebTable getTableStartingWithPrefix(java.lang.String text)
Returns the first table in the response which has the specified text as a prefix of the text in its first non-blank row and non-blank column. Will recurse into any nested tables, as needed.

Returns:
the selected table, or null if none is found

getTableWithSummary

public WebTable getTableWithSummary(java.lang.String summary)
Returns the first table in the response which has the specified text as its summary attribute. Will recurse into any nested tables, as needed.

Returns:
the selected table, or null if none is found

getTableWithID

public WebTable getTableWithID(java.lang.String ID)
Returns the first table in the response which has the specified text as its ID attribute. Will recurse into any nested tables, as needed.

Returns:
the selected table, or null if none is found

toString

public java.lang.String toString()

getFrames

public com.meterware.httpunit.WebFrame[] getFrames()
Returns the frames found in the page in the order in which they appear.


Copyright © 2000-2006 Russell Gold. See license agreement for rights granted.