Class ContainerNode
java.lang.Object
eu.maveniverse.domtrip.Node
eu.maveniverse.domtrip.ContainerNode
-
Nested Class Summary
Nested classes/interfaces inherited from class Node
Node.NodeType -
Field Summary
FieldsFields inherited from class Node
modified, parent, precedingWhitespace -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the givennodeas a child to thisContainerNode.child(int index) Gets the child at the specified index.intchildren()Returns aStreamof child nodes.voidRemoves all child nodes from thisContainerNode.voidGets the first child.getNode(int index) Deprecated.booleanbooleanvoidinsertChild(int index, Node node) Inserts a childNodeat the specified index.voidinsertChildAfter(Node referenceNode, Node newNode) Inserts a childNodeafter the specifiedreferenceNode, ifreferenceNodeis notnull; otherwise behaves the same asaddChild(newNode).voidinsertChildBefore(Node referenceNode, Node newNode) Inserts a childNodebefore the specifiedreferenceNode, ifreferenceNodeis notnull; otherwise behaves the same asaddChild(newNode).booleanisEmpty()Gets the last child.booleanremoveChild(Node node) Removes the given childNodefrom thisContainerNode.voidreplaceChild(Node existingNode, Node replacementNode) Replace theexistingNodeNodewith the givenreplacementNode, ifexistingNodeis notnull; otherwise behaves the same asaddChild(replacementNode).Methods inherited from class Node
accept, clone, copy, depth, document, isDescendantOf, isModified, markModified, nextSibling, nextSiblingElement, parent, parent, parentElement, precedingWhitespace, precedingWhitespace, previousSibling, previousSiblingElement, siblingIndex, toXml, toXml, type
-
Field Details
-
children
-
-
Constructor Details
-
ContainerNode
protected ContainerNode()
-
-
Method Details
-
children
-
addChild
Adds the givennodeas a child to thisContainerNode.- Parameters:
node- theNodeto add- Throws:
IllegalArgumentException- ifnodeisnull
-
insertChild
Inserts a childNodeat the specified index.- Parameters:
index- a zero based index at which to insert the specifiedNodenode- the node to insert- Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index > nodeCount())IllegalArgumentException- if node is null
-
insertChildBefore
Inserts a childNodebefore the specifiedreferenceNode, ifreferenceNodeis notnull; otherwise behaves the same asaddChild(newNode).- Parameters:
referenceNode- the node before which thenewNodeshould be insertednewNode- theNodeto insert- Throws:
IllegalArgumentException- ifnewNodeis or whenreferenceNodeis not a child of thisContainerNode- Since:
- 0.6.0
-
insertChildAfter
Inserts a childNodeafter the specifiedreferenceNode, ifreferenceNodeis notnull; otherwise behaves the same asaddChild(newNode).- Parameters:
referenceNode- the node after which thenewNodeshould be insertednewNode- theNodeto insert- Throws:
IllegalArgumentException- ifnewNodeis or whenreferenceNodeis not a child of thisContainerNode- Since:
- 0.6.0
-
replaceChild
Replace theexistingNodeNodewith the givenreplacementNode, ifexistingNodeis notnull; otherwise behaves the same asaddChild(replacementNode).- Parameters:
existingNode- theNodeto replacereplacementNode- theNodeto put in place ofexistingNode- Throws:
IllegalArgumentException- ifreplacementNodeisnullor whenexistingNodeis not a child of thisContainerNode- Since:
- 0.6.0
-
removeChild
Removes the given childNodefrom thisContainerNode.- Parameters:
node- theNodeto remove- Returns:
trueif thisContainerNodecontained the specifiedNodeandfalseotherwise
-
child
Gets the child at the specified index.- Parameters:
index- a zero based index of the childNodeto return- Returns:
- the child node at the specified index
- Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= nodeCount())
-
firstChild
Gets the first child.- Returns:
- an
Optionalholding the last first if thisContainerNodehas any children or otherwise and emptyOptional - Since:
- 0.6.0
-
lastChild
Gets the last child.- Returns:
- an
Optionalholding the last child if thisContainerNodehas any children or otherwise and emptyOptional - Since:
- 0.6.0
-
getNode
Deprecated.Usechild(int)instead.Gets the child node at the specified index.- Parameters:
index- the index of the child node- Returns:
- the child node at the specified index
-
childCount
public int childCount()- Returns:
- the number of child nodes
-
findTextNode
- Returns:
- and
Optionalholding the first text node child or an emptyOptionalif there is no text child under thisContainerNode
-
textContent
- Returns:
- the text content of this node (concatenates all text children).
-
hasChildElements
public boolean hasChildElements()- Returns:
trueif thisContainerNodehas any childElements orfalseotherwise
-
hasTextContent
public boolean hasTextContent()- Returns:
trueif thisContainerNodehas any childTextnodes orfalseotherwise
-
isEmpty
public boolean isEmpty()- Returns:
trueif thisContainerNodehas no child nodes orfalseotherwise
-
clearChildren
public void clearChildren()Removes all child nodes from thisContainerNode. -
clearModified
public void clearModified()- Overrides:
clearModifiedin classNode
-
child(int)instead.