public class VElement<P>
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 | Method | Description |
|---|---|---|
VElement<VElement<P>> |
add(java.lang.String name) |
Adds a child element of the specified name on the underlying element.
|
VElement<P> |
addSibling(java.lang.String name) |
Adds a sibling element of the specified name just before this one.
|
VElement<P> |
apply(java.util.function.Consumer<VElement<?>> 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.
|
VElement<P> |
attr(java.lang.String name,
java.lang.String value) |
Adds the specified attribute name/value on the underlying element.
|
VElement |
child(java.lang.String name) |
Returns the child first child of this element having the specified name.
|
java.util.List<VElement> |
children(java.lang.String name) |
Returns an unmodifiable list of the child elements having the specified name.
|
boolean |
exist() |
Returns
true if the underlying element exist. |
VElement<VElement<P>> |
get(java.lang.String name) |
Returns the first child element of the underlying element having the specified name.
|
java.lang.String |
getText() |
Returns the text pof the underlying element.
|
org.w3c.dom.Element |
getW3cElement() |
Returns the underlying w3cElement.
|
VElement<P> |
make() |
Creates the underlying element and its non-existing parents.
|
static VElement<java.lang.Void> |
of(org.w3c.dom.Element element) |
Creates a VElement wrapping the specified element.
|
static <P> VElement |
of(P parent,
org.w3c.dom.Element element) |
Creates a VElement wrapping the specified parent and element.
|
VElement<P> |
remove() |
Removes the underlying element from its parent children.
|
VElement<P> |
removeAttr(java.lang.String name) |
Removes the specified attribute of the specified name from the underlying element.
|
VElement<P> |
text(java.lang.String text) |
Sets the specified text on the underlying element.
|
java.lang.String |
toString() |
|
java.util.List<VElement> |
xPath(java.lang.String xPathExpression) |
Returns an unmodifiable list of elements matching the specified xPath expression.
|
java.util.List<VElement> |
xPath(javax.xml.xpath.XPathExpression xPathExpression) |
Returns an unmodifiable list of elements matching the specified xPath expression.
|
public final P __
public static VElement<java.lang.Void> of(org.w3c.dom.Element element)
public static <P> VElement of(P parent, org.w3c.dom.Element element)
public org.w3c.dom.Element getW3cElement()
public VElement<P> 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 VElement<P> removeAttr(java.lang.String name)
java.lang.IllegalStateException - if the underlying element does not exist.public VElement<P> text(java.lang.String text)
java.lang.IllegalStateException - if the underlying element does not exist.public java.lang.String getText()
null if the underlying element does not exist.public VElement<VElement<P>> add(java.lang.String name)
java.lang.IllegalStateException - if the underlying element does not exist.public VElement<VElement<P>> 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<VElement> children(java.lang.String name)
public VElement child(java.lang.String name)
null
if the underlying element does not exist or no such named child exists.public java.util.List<VElement> xPath(javax.xml.xpath.XPathExpression xPathExpression)
public java.util.List<VElement> xPath(java.lang.String xPathExpression)
public VElement<P> addSibling(java.lang.String name)
public VElement<P> apply(java.util.function.Consumer<VElement<?>> consumer)
public boolean exist()
true if the underlying element exist.public VElement<P> make()
public java.lang.String toString()
toString in class java.lang.Object