|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.jira.functest.framework.util.dom.DomKit
public class DomKit
This is some methods to manipulate the DOM and text in it
Constructor Summary | |
---|---|
DomKit()
|
Method Summary | |
---|---|
static Node |
betterNode(Node node)
This returns a Node implementation that has better toString() attached to it. |
static Node |
copyDOM(Node srcNode,
boolean convertTagsToLowerCase)
This will copy the Node ' s from srcNode into a new DocumentFragment |
static Element |
getBodyElement(Document document)
Returns the first BODY element of the Document or null if there isnt one |
static String |
getCollapsedText(Node node)
Returns the collapsed text of the specified Node. |
static Element |
getFirstParentByTag(Element element,
String parentTagName)
|
static String |
getHTML(Node node)
This will return an "canonical" version of the HTML that makes up the given Element , including itself. |
static Element |
getHtmlElement(Document document)
Returns the first HTML element of the Document or null if there isnt one |
static String |
getInnerHTML(Node node)
This will return an "canonical" version of the HTML that makes up the given Node , exclusing itself. |
static DocumentBuilder |
getNonValidatingDocumentBuilder()
Retrieves a thread-specific non validating DocumentBuilder . |
static String |
getRawText(Node node)
This returns a deep search of the raw text of a specified node. |
static Text[] |
getTextNodes(Element element)
Gets all the text nodes of an Element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DomKit()
Method Detail |
---|
public static DocumentBuilder getNonValidatingDocumentBuilder()
DocumentBuilder
. We do this because they are expensive to build.
DocumentBuilder
serving the current thread.public static Element getHtmlElement(Document document)
document
- the Document to search
public static Element getBodyElement(Document document)
document
- the Document to search
public static Element getFirstParentByTag(Element element, String parentTagName)
element
- the element to start searching fromparentTagName
- the tag name of the parent to retrieve
public static Text[] getTextNodes(Element element)
element
- the Element in play
public static String getCollapsedText(Node node)
node
- the Node to search
public static String getRawText(Node node)
node
- the Node
in question
public static String getInnerHTML(Node node)
Node
, exclusing itself.
HTML tags will be converted to lower case if they are not already.
node
- the Node in play
RuntimeException
- if the parsing is unsuccessfulpublic static String getHTML(Node node)
Element
, including itself.
HTML tags will be converted to lower case if they are not already. This is a suitabe default in JIRA even if the
object model of browsers and HttpUnit use uppercase for tags. It matches the JSP code we use in lower case.
node
- the Node in play
RuntimeException
- if the parsing is unsuccessfulpublic static Node copyDOM(Node srcNode, boolean convertTagsToLowerCase)
Node
' s from srcNode into a new DocumentFragment
srcNode
- the source element to copy fromconvertTagsToLowerCase
- whether to copy the element tags to lower case
IllegalArgumentException
- if the srcNode is not a Document
or Element
public static Node betterNode(Node node)
Node
implementation that has better toString() attached to it. Its useful inside a debugger
so you can easily see what content a node has. Each Node
that is linked to from this node
will also get the better toString() methods applied to it.
You can call this function safely on already wrapped Node objects since it can detect if they have already been wrapped
node
- the Node to make into a better one
Node
that has the new functionality
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |