public final class JkDomElement
extends java.lang.Object
Element
offering a Parent-Chaining fluent interface.
The underlying element may exist or not. If the underlying element does not exist,
a proxy element is used in place but write methods are disabled. The concrete w3c element
can be created afterward using the make()
method.
Modifier and Type | Field and Description |
---|---|
JkDomElement |
__ |
Modifier and Type | Method and Description |
---|---|
JkDomElement |
add(java.lang.String name)
Adds a child element of the specified name on the underlying element.
|
JkDomElement |
addSibling(java.lang.String name)
Adds a sibling element of the specified name just before this one.
|
JkDomElement |
apply(java.util.function.Consumer<JkDomElement> consumer)
Runs the specified consumer with this element as argument.
|
JkDomElement |
applyIf(boolean condition,
java.util.function.Consumer<JkDomElement> consumer)
Runs the specified consumer with this element as argument.
|
java.lang.String |
attr(java.lang.String name)
Returns the value of the specified attribute on this element.
|
JkDomElement |
attr(java.lang.String name,
java.lang.String value)
Adds the specified attribute name/value on the underlying element.
|
JkDomElement |
child(java.lang.String name)
Returns the child first child of this element having the specified name.
|
JkDomElement |
child(java.lang.String name,
java.util.function.Predicate<JkDomElement> predicate)
Returns the child first child of this element having the specified name and verifying the specified predicate.
|
java.util.List<JkDomElement> |
children(java.lang.String name)
Returns an unmodifiable list of the child elements having the specified name.
|
java.util.List<JkDomElement> |
children(java.lang.String name,
java.util.function.Predicate<JkDomElement> predicate)
Returns an unmodifiable list of the child elements having the specified name and verifying the specified predicate.
|
boolean |
exist()
Returns
true if the underlying element exist. |
JkDomElement |
get(java.lang.String name)
Returns the first child element of the underlying element having the specified name.
|
JkDomDocument |
getDoc() |
org.w3c.dom.Element |
getW3cElement()
Returns the underlying w3cElement.
|
JkDomElement |
make()
Creates the underlying element and its non-existing parents.
|
static JkDomElement |
of(org.w3c.dom.Element element)
Creates a VElement wrapping the specified element.
|
static <P> JkDomElement |
of(JkDomElement parent,
org.w3c.dom.Element element)
Creates a VElement wrapping the specified parent and element.
|
JkDomElement |
remove()
Removes the underlying element from its parent children.
|
JkDomElement |
removeAttr(java.lang.String name)
Removes the specified attribute of the specified name from the underlying element.
|
java.lang.String |
text()
Returns the text pof the underlying element.
|
JkDomElement |
text(java.lang.String text)
Sets the specified text on the underlying element.
|
java.lang.String |
toString() |
java.util.List<JkDomElement> |
xPath(java.lang.String xPathExpression)
Returns an unmodifiable list of elements matching the specified xPath expression.
|
java.util.List<JkDomElement> |
xPath(javax.xml.xpath.XPathExpression xPathExpression)
Returns an unmodifiable list of elements matching the specified xPath expression.
|
public final JkDomElement __
public static JkDomElement of(org.w3c.dom.Element element)
public static <P> JkDomElement of(JkDomElement parent, org.w3c.dom.Element element)
public org.w3c.dom.Element getW3cElement()
public JkDomElement attr(java.lang.String name, java.lang.String value)
java.lang.IllegalStateException
- if the underlying element does not exist.public java.lang.String attr(java.lang.String name)
null
if no such
attribute exists.public JkDomElement removeAttr(java.lang.String name)
java.lang.IllegalStateException
- if the underlying element does not exist.public JkDomElement text(java.lang.String text)
java.lang.IllegalStateException
- if the underlying element does not exist.public java.lang.String text()
null
if the underlying element does not exist.public JkDomElement add(java.lang.String name)
java.lang.IllegalStateException
- if the underlying element does not exist.public JkDomElement get(java.lang.String name)
If no such element exist, this method returns a proxy element that let creation possible afterward.
public java.util.List<JkDomElement> children(java.lang.String name, java.util.function.Predicate<JkDomElement> predicate)
public java.util.List<JkDomElement> children(java.lang.String name)
public JkDomElement child(java.lang.String name, java.util.function.Predicate<JkDomElement> predicate)
null if the underlying element does not exist or no such named child exists.
public JkDomElement child(java.lang.String name)
null if the underlying element does not exist or no such named child exists.
public java.util.List<JkDomElement> xPath(javax.xml.xpath.XPathExpression xPathExpression)
public java.util.List<JkDomElement> xPath(java.lang.String xPathExpression)
public JkDomElement addSibling(java.lang.String name)
public JkDomElement remove()
public JkDomElement apply(java.util.function.Consumer<JkDomElement> consumer)
public JkDomElement applyIf(boolean condition, java.util.function.Consumer<JkDomElement> consumer)
public JkDomDocument getDoc()
public boolean exist()
true
if the underlying element exist.public JkDomElement make()
public java.lang.String toString()
toString
in class java.lang.Object