com.uwyn.rife.test
Class ParsedHtml

java.lang.Object
  extended by com.uwyn.rife.test.ParsedHtml

public class ParsedHtml
extends Object

Retrieves the text content of a MockResponse and parses it as HTML.

Since:
1.1
Version:
$Revision: 3846 $
Author:
Geert Bevin (gbevin[remove] at uwyn dot com)

Method Summary
 Document getDocument()
          Retrieves the DOM XML document that corresponds to the parsed HTML.
 List<MockForm> getForms()
          Retrieves the list of all the forms in the HTML document.
 MockForm getFormWithId(String id)
          Retrieves the first form in the HTML document with a particular id attribute.
 MockForm getFormWithName(String name)
          Retrieves the first form in the HTML document with a particular name attribute.
 List<MockLink> getLinks()
          Retrieves the list of all the links in the HTML document.
 MockLink getLinkWithId(String id)
          Retrieves the first link in the HTML document with a particular id attribute.
 MockLink getLinkWithImageAlt(String alt)
          Retrieves the first link in the HTML document that surrounds an img tag with a certain alt attribute.
 MockLink getLinkWithImageName(String name)
          Retrieves the first link in the HTML document that surrounds an img tag with a certain name attribute.
 MockLink getLinkWithName(String name)
          Retrieves the first link in the HTML document with a particular name attribute.
 MockLink getLinkWithText(String text)
          Retrieves the first link in the HTML document that surrounds a particular text.
static String getNodeAttribute(Node node, String attributeName)
          Retrieves the value of the attribute of an XML DOM node.
 String getTitle()
          Retrieves the text of the title tag.
static ParsedHtml parse(MockResponse response)
          Parses the text content of a MockResponse object as HTML and returns the result as an instance of ParsedHtml.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parse

public static ParsedHtml parse(MockResponse response)
                        throws IOException,
                               SAXException
Parses the text content of a MockResponse object as HTML and returns the result as an instance of ParsedHtml.

Parameters:
response - the response whose text content will be parsed
Returns:
the resulting instance of ParsedHtml
Throws:
IOException
SAXException
Since:
1.1

getDocument

public Document getDocument()
Retrieves the DOM XML document that corresponds to the parsed HTML.

Returns:
the DOM XML document
Since:
1.1

getTitle

public String getTitle()
Retrieves the text of the title tag.

Returns:
the title
Since:
1.1

getForms

public List<MockForm> getForms()
Retrieves the list of all the forms in the HTML document.

Returns:
a list with MockForm instances
Since:
1.1
See Also:
getFormWithName(java.lang.String), getFormWithId(java.lang.String)

getFormWithName

public MockForm getFormWithName(String name)
Retrieves the first form in the HTML document with a particular name attribute.

Parameters:
name - the content of the name attribute
Returns:
the first MockForm whose name attribute matches; or

null if no such form could be found

Since:
1.1
See Also:
getForms(), getFormWithId(java.lang.String)

getFormWithId

public MockForm getFormWithId(String id)
Retrieves the first form in the HTML document with a particular id attribute.

Parameters:
id - the content of the id attribute
Returns:
the first MockForm whose id attribute matches; or

null if no such form could be found

Since:
1.1
See Also:
getForms(), getFormWithName(java.lang.String)

getLinks

public List<MockLink> getLinks()
Retrieves the list of all the links in the HTML document.

Returns:
a list with MockLink instances
Since:
1.1
See Also:
getLinkWithName(java.lang.String), getLinkWithId(java.lang.String), getLinkWithText(java.lang.String), getLinkWithImageAlt(java.lang.String), getLinkWithImageName(java.lang.String)

getLinkWithName

public MockLink getLinkWithName(String name)
Retrieves the first link in the HTML document with a particular name attribute.

Parameters:
name - the content of the name attribute
Returns:
the first MockLink whose name attribute matches; or

null if no such link could be found

Since:
1.1
See Also:
getLinks(), getLinkWithId(java.lang.String), getLinkWithText(java.lang.String), getLinkWithImageAlt(java.lang.String), getLinkWithImageName(java.lang.String)

getLinkWithId

public MockLink getLinkWithId(String id)
Retrieves the first link in the HTML document with a particular id attribute.

Parameters:
id - the content of the id attribute
Returns:
the first MockLink whose id attribute matches; or

null if no such link could be found

Since:
1.1
See Also:
getLinks(), getLinkWithName(java.lang.String), getLinkWithText(java.lang.String), getLinkWithImageAlt(java.lang.String), getLinkWithImageName(java.lang.String)

getLinkWithText

public MockLink getLinkWithText(String text)
Retrieves the first link in the HTML document that surrounds a particular text.

Parameters:
text - the surrounded text
Returns:
the first MockLink whose surrounded text matches; or

null if no such link could be found

Since:
1.1
See Also:
getLinks(), getLinkWithName(java.lang.String), getLinkWithId(java.lang.String), getLinkWithText(java.lang.String), getLinkWithImageName(java.lang.String)

getLinkWithImageAlt

public MockLink getLinkWithImageAlt(String alt)
Retrieves the first link in the HTML document that surrounds an img tag with a certain alt attribute.

Parameters:
alt - the content of the alt attribute
Returns:
the first MockLink that has an img tag whose alt attribute matches; or

null if no such link could be found

Since:
1.1
See Also:
getLinks(), getLinkWithName(java.lang.String), getLinkWithId(java.lang.String), getLinkWithText(java.lang.String), getLinkWithImageName(java.lang.String)

getLinkWithImageName

public MockLink getLinkWithImageName(String name)
Retrieves the first link in the HTML document that surrounds an img tag with a certain name attribute.

Parameters:
name - the content of the name attribute
Returns:
the first MockLink that has an img tag whose name attribute matches; or

null if no such link could be found

Since:
1.1
See Also:
getLinks(), getLinkWithName(java.lang.String), getLinkWithId(java.lang.String), getLinkWithText(java.lang.String), getLinkWithImageAlt(java.lang.String)

getNodeAttribute

public static String getNodeAttribute(Node node,
                                      String attributeName)
Retrieves the value of the attribute of an XML DOM node.

Parameters:
node - the node where the attribute should be obtained from
attributeName - the name of the attribute
Returns:
the value of the attribute; or

null if no attribute could be found

Since:
1.2


Copyright © 2001-2007 Uwyn sprl/bvba. All Rights Reserved.