Constructor and Description |
---|
XMLNode(Node node)
Initializes this object given an XML node.
|
XMLNode(String name)
Initializes this object given a name.
|
Modifier and Type | Method and Description |
---|---|
void |
addNewChildNode(XMLNode newChildNode)
Adds a new child node to this node.
|
void |
addNewChildNodeInTheBeginning(XMLNode newChildNode)
Adds a new child node as the first child node of this node.
|
void |
addNewChildNodes(XMLNodeList newChildNodes)
Adds a list of nodes as child nodes to this node.
|
XMLNode |
getChildNodeByName(String name)
Returns the first child node of this node by name.
|
XMLNodeList |
getChildNodes()
Returns the child nodes of this node.
|
XMLNodeList |
getChildNodesByName(String name)
Returns a list of the child nodes of this node by name.
|
XMLNodeList |
getChildNodesRecursivelyByName(Set<String> names)
Returns all child nodes that have the given names resursively.
|
XMLNodeList |
getChildNodesRecursivelyByName(String... names)
Returns all child nodes that have the given names resursively.
|
XMLNodeList |
getDeepChildNodesRecursivelyByName(Set<String> names)
Returns all deep child nodes that have the given names resursively.
|
XMLNodeList |
getDeepChildNodesRecursivelyByName(String... names)
Returns all deep child nodes that have the given names resursively.
|
XMLNode |
getParentNode()
Returns the parent node of this node.
|
String |
getTextContent()
Returns the content of this node as a string.
|
boolean |
hasMoreThanOneChildren()
Checks if this node has more than one children.
|
boolean |
hasName(Set<String> names)
Checks if the name of this node is contained in the given set.
|
boolean |
hasName(String... names)
Checks if the name of this node is contained in the given strings.
|
boolean |
hasName(String name)
Checks if this node has the given name.
|
void |
insertNewParentNode(XMLNode newParentNode)
Replaces the parent node of this node with the given new parent node.
|
boolean |
isTextNode()
Checks if this node is a text node.
|
XMLNode |
removeChild(XMLNode child)
Removes and returns the given child from this node.
|
void |
removeParentNode()
Removes the parent node of this node.
|
void |
replaceChild(XMLNode newChild,
XMLNode oldChild)
Replaces a child node of this node with another new child node.
|
boolean |
textContentStartsWith(String text)
Denotes whether the text content of this node starts with the given text.
|
String |
toString()
Returns a string representation of this node as a string representation of the inner node.
|
String |
toXMLString()
Returns the XML representation of this node.
|
public XMLNode(Node node)
node
- the inner node object.public XMLNode(String name)
name
- the name of the node object.public XMLNodeList getChildNodesByName(String name)
name
- the name of the child nodes that are returned.public XMLNode getChildNodeByName(String name)
name
- the name of the returned child node.public String getTextContent()
public boolean hasMoreThanOneChildren()
true
if this node has more than one children, or false
otherwise.public XMLNodeList getChildNodesRecursivelyByName(Set<String> names)
names
- the names for which the child nodes are found.public XMLNodeList getChildNodesRecursivelyByName(String... names)
names
- the names for which the child nodes are found.public XMLNodeList getDeepChildNodesRecursivelyByName(Set<String> names)
names
- the names for which the child nodes are found.public XMLNodeList getDeepChildNodesRecursivelyByName(String... names)
names
- the names for which the child nodes are found.public boolean hasName(String name)
name
- the name of this node to be checked.true
if this node has the given name, or false
otherwise.public boolean hasName(Set<String> names)
names
- a set of names to be checked whether it contains the name of this node.true
if the name of this node is contained in the given set, or false
otherwise.public boolean hasName(String... names)
names
- a set of strings to be checked whether they include the name of this node.true
if the name of this node is contained in the given strings, or false
otherwise.public XMLNodeList getChildNodes()
public boolean isTextNode()
true
if this node is a text node, or false
otherwise.public XMLNode getParentNode()
public boolean textContentStartsWith(String text)
text
- the text to check if it is the start of the contents of this node.true
if the the text content of this node starts with the given text, or false
otherwise.public void insertNewParentNode(XMLNode newParentNode)
newParentNode
- the new parent node of this node.public void addNewChildNode(XMLNode newChildNode)
newChildNode
- the node to be added as a new child node to this node.public void addNewChildNodes(XMLNodeList newChildNodes)
newChildNodes
- the list of nodes to be added as new child nodes to this node.public void removeParentNode()
public void replaceChild(XMLNode newChild, XMLNode oldChild)
newChild
- the child to replace the current child.oldChild
- the child that is replaced.public XMLNode removeChild(XMLNode child)
child
- the child node to be removed.public void addNewChildNodeInTheBeginning(XMLNode newChildNode)
newChildNode
- the new child node to be added to the children of this node.public String toXMLString()
Copyright © 2017. All rights reserved.