|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.ditchnet.xml.dom.DomUtils
A Utility class that may not be instanciated (private constructor) that contains static utility methods that ease DOM traversal pain.
| Method Summary | |
static java.util.List |
getChildrenByClassName(org.w3c.dom.Node target,
java.lang.String className)
Returns all child elements of target with HTML
class attribute values that contain className
as an array of type List. |
static java.util.List |
getDescendantsByClassName(org.w3c.dom.Node target,
java.lang.String className)
Returns all descendant elements of target with HTML
class attribute values that contain className
as an array of type List. |
static org.w3c.dom.Element |
getFirstAncestorByClassName(org.w3c.dom.Node target,
java.lang.String className)
Search up the DOM tree for the first ancestor element of
target with an HTML class attribute value of
className. |
static org.w3c.dom.Element |
getFirstAncestorOrSelfByClassName(org.w3c.dom.Node target,
java.lang.String className)
Search up the DOM tree for the first ancestor element of
target with an HTML class attribute value of
className. |
static org.w3c.dom.Element |
getFirstChildByClassName(org.w3c.dom.Node target,
java.lang.String className)
Search target's children for the first element node
with an HTML class attribute value of
className. |
static org.w3c.dom.Element |
getFirstDescendantByClassNameBreadthFirst(org.w3c.dom.Node target,
java.lang.String className)
Retreives target's first descendant element with an
HTML class attribute value that includes
className using a breadth-first algorithm. |
static org.w3c.dom.Element |
getFirstDescendantByClassNameDepthFirst(org.w3c.dom.Node target,
java.lang.String className)
Retreives target's first descendant element with an
HTML class attribute value that includes
className using a depth-first algorithm. |
static boolean |
hasClassName(org.w3c.dom.Element target,
java.lang.String className)
Test the target param to see if it's HTML class
attribute contains className. |
static boolean |
hasId(org.w3c.dom.Element target,
java.lang.String id)
Test Element param to see if it's HTML id
attribute matches id. |
static boolean |
isElementNode(org.w3c.dom.Node target)
Tests to see if target's getNodeType()
method returns Node.ELEMENT_NODE. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static boolean hasId(org.w3c.dom.Element target,
java.lang.String id)
Element param to see if it's HTML id
attribute matches id.
target - The Element to test.id - Check target for this value in it's HTML
id attribute.
public static boolean hasClassName(org.w3c.dom.Element target,
java.lang.String className)
target param to see if it's HTML class
attribute contains className. Keep in mind that the HTML
4.01 spec allows an element's HTML class attribute value
to consist of multiple space-separated values. This method takes that
fact into account, and tests target's HTML class attribute
for the existence of className anywhere in the string.
So for example, say you had an org.w3c.dom.Element
reference to the following HTML element in a variable named
target:
<div class="ditch-tab-pane ditch-focused"></div>
note that this attribute value is taking advantage of the ability to list multiple space separated values.
DomUtils.hasClassName(target,"ditch-tab-pane");
Would return true.
DomUtils.hasClassName(target,"ditch-tab");
Would return false.
target - The Element to test.className - Check target for this value in it's HTML
class attribute.public static boolean isElementNode(org.w3c.dom.Node target)
target's getNodeType()
method returns Node.ELEMENT_NODE.
public static org.w3c.dom.Element getFirstAncestorByClassName(org.w3c.dom.Node target,
java.lang.String className)
target with an HTML class attribute value of
className.
public static org.w3c.dom.Element getFirstAncestorOrSelfByClassName(org.w3c.dom.Node target,
java.lang.String className)
target with an HTML class attribute value of
className.
public static org.w3c.dom.Element getFirstChildByClassName(org.w3c.dom.Node target,
java.lang.String className)
target's children for the first element node
with an HTML class attribute value of
className.
public static org.w3c.dom.Element getFirstDescendantByClassNameBreadthFirst(org.w3c.dom.Node target,
java.lang.String className)
target's first descendant element with an
HTML class attribute value that includes
className using a breadth-first algorithm.
public static org.w3c.dom.Element getFirstDescendantByClassNameDepthFirst(org.w3c.dom.Node target,
java.lang.String className)
target's first descendant element with an
HTML class attribute value that includes
className using a depth-first algorithm.
public static java.util.List getChildrenByClassName(org.w3c.dom.Node target,
java.lang.String className)
target with HTML
class attribute values that contain className
as an array of type List. NOTE that unlike the
algorithms specified in the DOM spec, a NodeList is NOT
returned. This method searches only one level deep...
target's child nodes.
public static java.util.List getDescendantsByClassName(org.w3c.dom.Node target,
java.lang.String className)
target with HTML
class attribute values that contain className
as an array of type List. NOTE that unlike the
algorithms specified in the DOM spec, a NodeList is NOT
returned. This method searched for all descendants of target
meeting the criteria using a breadth-first algorithm.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||