public abstract class

AbstractLocator

extends Object
implements Locator
java.lang.Object
   ↳ com.atlassian.jira.functest.framework.locator.AbstractLocator
Known Direct Subclasses

Class Overview

A base class to derive Locators from

Summary

Nested Classes
interface AbstractLocator.LocatorTextOperation  
Fields
protected Node[] nodes
protected WebResponse originalWebResponse
protected WebTester tester
Protected Constructors
AbstractLocator()
AbstractLocator(WebTester tester)
Public Methods
Iterable<LocatorEntry> allMatches()
Get all matches of this locator as an iterable collection of locator entries
boolean exists()
Return true at least one element will be matches by this locator.
String getHTML()
Returns the HTML that a called to 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.
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.
boolean hasNodes()
This will return true if the Locator found some org.w3c.dom.Node's.
Iterator<LocatorEntry> iterator()
This will return a Iterator that returns LocatorEntry objects
Protected Methods
Node betterNode(Node node)
static boolean containsNode(Locator locator, Node node)
Document getDOM(WebTester tester)
Returns the DOM Document from the WebTester.
String getNodeTextImpl(Node node, AbstractLocator.LocatorTextOperation textOperation)
Called to get the test or HTML of an org.w3c.dom.Node
String getNodesTextImpl(Node[] nodes, AbstractLocator.LocatorTextOperation textOperation)
Called to get all the text or HTML of a set of org.w3c.dom.Node's.
WebResponse getWebResponse(WebTester tester)
synchronized String toStringImpl(String concreteImplementationName)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.functest.framework.locator.Locator

Fields

protected Node[] nodes

protected WebResponse originalWebResponse

protected WebTester tester

Protected Constructors

protected AbstractLocator ()

protected AbstractLocator (WebTester tester)

Public Methods

public Iterable<LocatorEntry> allMatches ()

Get all matches of this locator as an iterable collection of locator entries

Returns
  • iterable collection of locator entries representing matches of this locator

public boolean exists ()

Return true at least one element will be matches by this locator.

Returns
  • true if the locator will match one element or false otherwise.

public String getHTML ()

Returns the HTML that a called to getNodes() represent, including the top level nodes themselves.

Returns
  • the HTML of the nodes

public String getHTML (Node node)

Returns the HTML of the specified node. The node MUST be one of the nodes that a call to getNodes() would return.

Parameters
node the node that we previously returned by a call to getNodes()
Returns
  • the HTML of the node

public 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.

Returns
  • null if not nodes found or the getNodes()[0]

public String getRawText ()

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 org.w3c.dom.Text nodes appended together with not whitespace removal at all.

Returns
  • the text of the Nodes that the locator is designed to locate.

public String getRawText (Node node)

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 org.w3c.dom.Text nodes appended together with not whitespace removal at all.

Parameters
node the node that we previously returned by a call to getNodes()
Returns
  • the text of the Node according to this Locator

public String getText ()

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 org.w3c.dom.Text nodes smooshed together to removed repeating whitespace.

Returns
  • the text of the Nodes that the locator is designed to locate.

public String getText (Node node)

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 org.w3c.dom.Text nodes smooshed together to removed repeating whitespace.

Parameters
node the node that we previously returned by a call to getNodes()
Returns
  • the text f the Node according to this Locator

public boolean hasNodes ()

This will return true if the Locator found some org.w3c.dom.Node's. This is really a convenience method for getNodes().length > 0

Returns
  • true if the Locator found some nodes

public Iterator<LocatorEntry> iterator ()

This will return a Iterator that returns LocatorEntry objects

Returns

Protected Methods

protected Node betterNode (Node node)

protected static boolean containsNode (Locator locator, Node node)

protected Document getDOM (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

protected String getNodeTextImpl (Node node, AbstractLocator.LocatorTextOperation textOperation)

Called to get the test or HTML of an org.w3c.dom.Node

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

protected String getNodesTextImpl (Node[] nodes, AbstractLocator.LocatorTextOperation textOperation)

Called to get all the text or HTML of a set of org.w3c.dom.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

protected WebResponse getWebResponse (WebTester tester)

protected synchronized String toStringImpl (String concreteImplementationName)