org.specrunner.util.xom
Class UtilNode

java.lang.Object
  extended by org.specrunner.util.xom.UtilNode

public final class UtilNode
extends Object

Node utility class.

Author:
Thiago Santos

Field Summary
static String ATT_CSS
          The CSS attribute name.
static String CSS_LETF
          The CSS which set the left argument.
static String CSS_RIGHT
          The CSS which set the right argument.
static String IGNORE
          Any node in specification with attribute "ignore=true" will not be evaluated.
static String PENDING
          Any node in specification with attribute "pending=true" will be considered a pending item.
 
Method Summary
static nu.xom.Node appendCss(nu.xom.Node node, String css)
          Add a CSS to the node.
static String getChildrenAsString(nu.xom.Node parent)
          Get child elements as a String.
static nu.xom.Node getCssNode(nu.xom.Node root, String css)
          Get the highest node with the style given.
static int getDepth(nu.xom.Node node)
          Get the node depth in the specification.
static nu.xom.Node getHighest(nu.xom.Nodes nodes)
          Get the highest node in the specification hierarchy.
static nu.xom.Node getLeft(nu.xom.Node root)
          Get highest descendant node with class 'CSS_LEFT'.
static nu.xom.Node getRight(nu.xom.Node root)
          Get highest descendant node with class 'CSS_RIGHT'.
static boolean isElement(nu.xom.Node node, String tag)
          Check if a node is of a given tag type.
static boolean isIgnore(nu.xom.Node node)
          Check is a node is marked to be ignored.
static boolean isPending(nu.xom.Node node)
          Check is a node is marked as pending.
static boolean isTable(nu.xom.Node node)
          Check if a node is a table.
static boolean matches(nu.xom.Node node, String xpath)
          Check if node matchs the XPath.
static INodeHolder newNodeHolder(nu.xom.Node node)
          Creates a element adapter for the given node.
static TableAdapter newTableAdapter(nu.xom.Node node)
          Creates a table adapter for the given node.
static void removeCss(nu.xom.Node node, String css)
          Remove a CSS from node.
static void setIgnore(nu.xom.Node node)
          Adds the information that a given node might be ignored by runners.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IGNORE

public static final String IGNORE
Any node in specification with attribute "ignore=true" will not be evaluated. Ignore is also used in plugin specific features such as to avoid cell comparison inside tables in WebDriver profile.

See Also:
Constant Field Values

PENDING

public static final String PENDING
Any node in specification with attribute "pending=true" will be considered a pending item.

See Also:
Constant Field Values

ATT_CSS

public static final String ATT_CSS
The CSS attribute name.

See Also:
Constant Field Values

CSS_LETF

public static final String CSS_LETF
The CSS which set the left argument.

See Also:
Constant Field Values

CSS_RIGHT

public static final String CSS_RIGHT
The CSS which set the right argument.

See Also:
Constant Field Values
Method Detail

isIgnore

public static boolean isIgnore(nu.xom.Node node)
Check is a node is marked to be ignored.

Parameters:
node - The node to be checked.
Returns:
true, if node can be ignored, false, otherwise.

isPending

public static boolean isPending(nu.xom.Node node)
Check is a node is marked as pending.

Parameters:
node - The node to be checked.
Returns:
true, if node is pending, false, otherwise.

setIgnore

public static void setIgnore(nu.xom.Node node)
Adds the information that a given node might be ignored by runners.

Parameters:
node - The node to be ignored.

appendCss

public static nu.xom.Node appendCss(nu.xom.Node node,
                                    String css)
Add a CSS to the node.

Parameters:
node - The node.
css - The css to be added (appended).
Returns:
The node.

removeCss

public static void removeCss(nu.xom.Node node,
                             String css)
Remove a CSS from node.

Parameters:
node - Node object.
css - The node.

getChildrenAsString

public static String getChildrenAsString(nu.xom.Node parent)
Get child elements as a String.

Parameters:
parent - The parent element.
Returns:
The inner XML.

getHighest

public static nu.xom.Node getHighest(nu.xom.Nodes nodes)
Get the highest node in the specification hierarchy.

Parameters:
nodes - List of nodes.
Returns:
The highest node.

getDepth

public static int getDepth(nu.xom.Node node)
Get the node depth in the specification.

Parameters:
node - The node.
Returns:
The height.

matches

public static boolean matches(nu.xom.Node node,
                              String xpath)
Check if node matchs the XPath.

Parameters:
node - The node.
xpath - The xpath.
Returns:
true, if matched, false, otherwise.

isTable

public static boolean isTable(nu.xom.Node node)
Check if a node is a table.

Parameters:
node - The node.
Returns:
true, if is a table, false, otherwise.

newTableAdapter

public static TableAdapter newTableAdapter(nu.xom.Node node)
Creates a table adapter for the given node.

Parameters:
node - The node.
Returns:
The adapter.

newNodeHolder

public static INodeHolder newNodeHolder(nu.xom.Node node)
Creates a element adapter for the given node.

Parameters:
node - The node.
Returns:
The adapter.

getLeft

public static nu.xom.Node getLeft(nu.xom.Node root)
                           throws PluginException
Get highest descendant node with class 'CSS_LEFT'.

Parameters:
root - The root.
Returns:
The node, if exist.
Throws:
PluginException - If node does not exist.

getRight

public static nu.xom.Node getRight(nu.xom.Node root)
                            throws PluginException
Get highest descendant node with class 'CSS_RIGHT'.

Parameters:
root - The root.
Returns:
The node, if exist.
Throws:
PluginException - If node does not exist.

getCssNode

public static nu.xom.Node getCssNode(nu.xom.Node root,
                                     String css)
                              throws PluginException
Get the highest node with the style given.

Parameters:
root - The root node.
css - The expected css.
Returns:
The expected node.
Throws:
PluginException - If child with css does not exist.

isElement

public static boolean isElement(nu.xom.Node node,
                                String tag)
Check if a node is of a given tag type.

Parameters:
node - The node.
tag - The tag.
Returns:
true, if is element of given tag name, false, otherwise.


Copyright © 2014. All rights reserved.