com.meterware.httpunit
Interface HTMLSegment

All Known Implementing Classes:
BlockElement, WebResponse

public interface HTMLSegment

Represents the parse tree for a segment of HTML.

Author:
Russell Gold

Method Summary
 WebApplet[] getApplets()
          Returns the applets found in the page in the order in which they appear.
 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 HTMLElements found with the specified attribute value.
 HTMLElement[] getElementsWithName(java.lang.String name)
          Returns the HTMLElements found in this segment with the specified name.
 HTMLElement getElementWithID(java.lang.String id)
          Returns the HTMLElement found in this segment with the specified ID.
 WebForm getFirstMatchingForm(HTMLElementPredicate predicate, java.lang.Object value)
          Returns the first form found in the page matching the specified criteria.
 WebLink getFirstMatchingLink(HTMLElementPredicate predicate, java.lang.Object value)
          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.
 WebForm[] getForms()
          Returns the forms found in this HTML segment in the order in which they appear.
 WebForm getFormWithID(java.lang.String ID)
          Returns the form found in this HTML segment with the specified ID.
 WebForm getFormWithName(java.lang.String name)
          Returns the form found in this HTML segment with the specified name.
 WebImage[] getImages()
          Returns the images found in the page in the order in which they appear.
 WebImage getImageWithAltText(java.lang.String source)
          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 this HTML segment in the order in which they appear.
 WebLink getLinkWith(java.lang.String text)
          Returns the first link which contains the specified text.
 WebLink getLinkWithImageText(java.lang.String text)
          Returns the first link which contains an image with the specified text as its 'alt' attribute.
 WebForm[] getMatchingForms(HTMLElementPredicate predicate, java.lang.Object criteria)
          Returns all forms 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 all tables found in the page matching the specified criteria.
 WebTable[] getTables()
          Returns the top-level tables found in this HTML segment in the order in which they appear.
 WebTable getTableStartingWith(java.lang.String text)
          Returns the first table in this HTML segment 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 this HTML segment 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 this HTML segment which has the specified text as its ID attribute.
 WebTable getTableWithSummary(java.lang.String summary)
          Returns the first table in this HTML segment which has the specified text as its summary attribute.
 TextBlock[] getTextBlocks()
          Returns the top-level block elements found in the page in the order in which they appear.
 

Method Detail

getElementWithID

public HTMLElement getElementWithID(java.lang.String id)
                             throws org.xml.sax.SAXException
Returns the HTMLElement found in this segment with the specified ID.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getElementsWithName

public HTMLElement[] getElementsWithName(java.lang.String name)
                                  throws org.xml.sax.SAXException
Returns the HTMLElements found in this segment with the specified name.

Throws:
org.xml.sax.SAXException

getElementsWithAttribute

public HTMLElement[] getElementsWithAttribute(java.lang.String name,
                                              java.lang.String value)
                                       throws org.xml.sax.SAXException
Returns the HTMLElements found with the specified attribute value.

Throws:
org.xml.sax.SAXException
Since:
1.6

getElementNames

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

Throws:
org.xml.sax.SAXException

getForms

public WebForm[] getForms()
                   throws org.xml.sax.SAXException
Returns the forms found in this HTML segment in the order in which they appear.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getFormWithID

public WebForm getFormWithID(java.lang.String ID)
                      throws org.xml.sax.SAXException
Returns the form found in this HTML segment with the specified ID.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getFormWithName

public WebForm getFormWithName(java.lang.String name)
                        throws org.xml.sax.SAXException
Returns the form found in this HTML segment with the specified name.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getFirstMatchingForm

public WebForm getFirstMatchingForm(HTMLElementPredicate predicate,
                                    java.lang.Object value)
                             throws org.xml.sax.SAXException
Returns the first form found in the page matching the specified criteria.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the response.

getMatchingForms

public WebForm[] getMatchingForms(HTMLElementPredicate predicate,
                                  java.lang.Object criteria)
                           throws org.xml.sax.SAXException
Returns all forms found in the page matching the specified criteria.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the response.

getLinks

public WebLink[] getLinks()
                   throws org.xml.sax.SAXException
Returns the links found in this HTML segment in the order in which they appear.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getLinkWith

public WebLink getLinkWith(java.lang.String text)
                    throws org.xml.sax.SAXException
Returns the first link which contains the specified text.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getLinkWithImageText

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

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getFirstMatchingLink

public WebLink getFirstMatchingLink(HTMLElementPredicate predicate,
                                    java.lang.Object value)
                             throws org.xml.sax.SAXException
Returns the first link found in the page matching the specified criteria.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the response.

getMatchingLinks

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

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the response.

getImages

public WebImage[] getImages()
                     throws org.xml.sax.SAXException
Returns the images found in the page in the order in which they appear.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getImageWithName

public WebImage getImageWithName(java.lang.String name)
                          throws org.xml.sax.SAXException
Returns the image found in the page with the specified name.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getImageWithSource

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

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getImageWithAltText

public WebImage getImageWithAltText(java.lang.String source)
                             throws org.xml.sax.SAXException
Returns the first image found in the page with the specified alt attribute.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getApplets

public WebApplet[] getApplets()
                       throws org.xml.sax.SAXException
Returns the applets found in the page in the order in which they appear.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getTextBlocks

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

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.
Since:
1.6

getTables

public WebTable[] getTables()
                     throws org.xml.sax.SAXException
Returns the top-level tables found in this HTML segment in the order in which they appear.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getFirstMatchingTable

public WebTable getFirstMatchingTable(HTMLElementPredicate predicate,
                                      java.lang.Object criteria)
                               throws org.xml.sax.SAXException
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
Throws:
org.xml.sax.SAXException

getMatchingTables

public WebTable[] getMatchingTables(HTMLElementPredicate predicate,
                                    java.lang.Object criteria)
                             throws org.xml.sax.SAXException
Returns all tables found in the page matching the specified criteria.

Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the response.

getTableStartingWith

public WebTable getTableStartingWith(java.lang.String text)
                              throws org.xml.sax.SAXException
Returns the first table in this HTML segment 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
Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getTableStartingWithPrefix

public WebTable getTableStartingWithPrefix(java.lang.String text)
                                    throws org.xml.sax.SAXException
Returns the first table in this HTML segment 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
Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getTableWithSummary

public WebTable getTableWithSummary(java.lang.String summary)
                             throws org.xml.sax.SAXException
Returns the first table in this HTML segment 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
Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

getTableWithID

public WebTable getTableWithID(java.lang.String ID)
                        throws org.xml.sax.SAXException
Returns the first table in this HTML segment 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
Throws:
org.xml.sax.SAXException - thrown if there is an error parsing the segment.

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