com.atlassian.jira.functest.framework.locator
Class AbstractLocator

java.lang.Object
  extended by com.atlassian.jira.functest.framework.locator.AbstractLocator
All Implemented Interfaces:
Locator
Direct Known Subclasses:
AggregateLocator, CssLocator, IdLocator, NodeLocator, TableCellLocator, TableLocator, WebPageLocator, XPathLocator

public abstract class AbstractLocator
extends Object
implements Locator

A base class to derive Locators from

Since:
v3.13

Nested Class Summary
protected static interface AbstractLocator.LocatorTextOperation
           
 
Field Summary
protected  Node[] nodes
           
protected  com.meterware.httpunit.WebResponse originalWebResponse
           
protected  net.sourceforge.jwebunit.WebTester tester
           
 
Constructor Summary
protected AbstractLocator()
           
protected AbstractLocator(net.sourceforge.jwebunit.WebTester tester)
           
 
Method Summary
 Iterable<LocatorEntry> allMatches()
          Get all matches of this locator as an iterable collection of locatore entries
protected  Node betterNode(Node node)
           
protected static boolean containsNode(Locator locator, Node node)
           
 boolean exists()
          Return true at least one element will be matches by this locator.
protected  Document getDOM(net.sourceforge.jwebunit.WebTester tester)
          Returns the DOM Document from the WebTester.
 String getHTML()
          Returns the HTML that a called to Locator.getNodes() represent, including the top level nodes themselves.
 String getHTML(Node node)
          Returns the HTML of the specified node.
 Node getNode()
          This convenience methods is the the equivalent of getNodes()[0] except when the number of nodes found is zero, in which case it should return null.
protected  String getNodesTextImpl(Node[] nodes, AbstractLocator.LocatorTextOperation textOperation)
          Called to get all the text or HTML of a set of Node's.
protected  String getNodeTextImpl(Node node, AbstractLocator.LocatorTextOperation textOperation)
          Called to get the test or HTML of an Node
 String getRawText()
          Returns the combined raw text of the Nodes that getNodes() would return or empty string.
 String getRawText(Node node)
          Returns the raw text of the specified Node.
 String getText()
          Returns the combined collapsed text of the Nodes that getNodes() would return or empty string.
 String getText(Node node)
          Returns the collapsed text of the specified Node.
protected  com.meterware.httpunit.WebResponse getWebResponse(net.sourceforge.jwebunit.WebTester tester)
           
 boolean hasNodes()
          This will return true if the Locator found some Node's.
 Iterator<LocatorEntry> iterator()
          This will return a Iterator that returns LocatorEntry objects
protected  String toStringImpl(String concreteImplementationName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.jira.functest.framework.locator.Locator
getNodes, toString
 

Field Detail

tester

protected net.sourceforge.jwebunit.WebTester tester

originalWebResponse

protected com.meterware.httpunit.WebResponse originalWebResponse

nodes

protected Node[] nodes
Constructor Detail

AbstractLocator

protected AbstractLocator()

AbstractLocator

protected AbstractLocator(net.sourceforge.jwebunit.WebTester tester)
Method Detail

betterNode

protected Node betterNode(Node node)

exists

public boolean exists()
Description copied from interface: Locator
Return true at least one element will be matches by this locator.

Specified by:
exists in interface Locator
Returns:
true if the locator will match one element or false otherwise.

getNode

public Node getNode()
Description copied from interface: Locator
This convenience methods is the the equivalent of getNodes()[0] except when the number of nodes found is zero, in which case it should return null.

Specified by:
getNode in interface Locator
Returns:
null if not nodes found or the getNodes()[0]

iterator

public Iterator<LocatorEntry> iterator()
Description copied from interface: Locator
This will return a Iterator that returns LocatorEntry objects

Specified by:
iterator in interface Locator
Returns:
a Iterator that returns LocatorEntry objects

allMatches

public Iterable<LocatorEntry> allMatches()
Description copied from interface: Locator
Get all matches of this locator as an iterable collection of locatore entries

Specified by:
allMatches in interface Locator
Returns:
iterable collection of locator entries representing matches of this locator

hasNodes

public boolean hasNodes()
Description copied from interface: Locator
This will return true if the Locator found some Node's. This is really a convenience method for getNodes().length > 0

Specified by:
hasNodes in interface Locator
Returns:
true if the Locator found some nodes

getDOM

protected Document getDOM(net.sourceforge.jwebunit.WebTester tester)
Returns the DOM Document from the WebTester. This is useful to override in tests

Parameters:
tester - the WebTester in play
Returns:
the Document from the web tester

getText

public String getText()
Description copied from interface: Locator
Returns the combined collapsed text of the Nodes that getNodes() would return or empty string.

NOTE : This text is the "COLLAPSED" text of the nodes, that is all the child Text nodes smooshed together to removed repeating whitespace.

Specified by:
getText in interface Locator
Returns:
the text of the Nodes that the locator is designed to locate.

getText

public String getText(Node node)
Description copied from interface: Locator
Returns the collapsed text of the specified Node. The node MUST be one of the nodes that a call to getNodes() would return.

NOTE : This text is the "COLLAPSED" text of the node, that is all the child Text nodes smooshed together to removed repeating whitespace.

Specified by:
getText in interface Locator
Parameters:
node - the node that we previously returned by a call to getNodes()
Returns:
the text f the Node according to this Locator

getRawText

public String getRawText()
Description copied from interface: Locator
Returns the combined raw text of the Nodes that getNodes() would return or empty string.

NOTE : This text is the "RAW" text of the nodes, that is all the child Text nodes appended together with not whitespace removal at all.

Specified by:
getRawText in interface Locator
Returns:
the text of the Nodes that the locator is designed to locate.

getRawText

public String getRawText(Node node)
Description copied from interface: Locator
Returns the raw text of the specified Node. The node MUST be one of the nodes that a call to getNodes() would return.

NOTE : This text is the "RAW" text of the node, that is all the child Text nodes appended together with not whitespace removal at all.

Specified by:
getRawText in interface Locator
Parameters:
node - the node that we previously returned by a call to getNodes()
Returns:
the text of the Node according to this Locator

getHTML

public String getHTML()
Description copied from interface: Locator
Returns the HTML that a called to Locator.getNodes() represent, including the top level nodes themselves.

Specified by:
getHTML in interface Locator
Returns:
the HTML of the nodes

getHTML

public String getHTML(Node node)
Description copied from interface: Locator
Returns the HTML of the specified node. The node MUST be one of the nodes that a call to getNodes() would return.

Specified by:
getHTML in interface Locator
Parameters:
node - the node that we previously returned by a call to getNodes()
Returns:
the HTML of the node

getNodeTextImpl

protected String getNodeTextImpl(Node node,
                                 AbstractLocator.LocatorTextOperation textOperation)
Called to get the test or HTML of an Node

Parameters:
node - the Node
textOperation - the type of text operation
Returns:
the text of the Node, inclusive of the node itself

getNodesTextImpl

protected String getNodesTextImpl(Node[] nodes,
                                  AbstractLocator.LocatorTextOperation textOperation)
Called to get all the text or HTML of a set of Node's. Makes a call to AbstractLocator#getNodeHtmlImpl for each node and appends it.

Parameters:
nodes - the Nodes to get text for
textOperation - the type of text operation
Returns:
the text of all the Nodes appended together

containsNode

protected static boolean containsNode(Locator locator,
                                      Node node)

getWebResponse

protected com.meterware.httpunit.WebResponse getWebResponse(net.sourceforge.jwebunit.WebTester tester)

toStringImpl

protected String toStringImpl(String concreteImplementationName)


Copyright © 2002-2012 Atlassian. All Rights Reserved.