public class XMLNode
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
attributes
The attributes.
|
protected java.util.List<XMLNode> |
children
The children nodes.
|
protected java.lang.String |
name
The node name.
|
protected XMLNode |
nodeParent
The node parent.
|
Constructor and Description |
---|
XMLNode(java.lang.String nodeName)
Create the Node.
|
XMLNode(XMLNode parent,
java.lang.String nodeName)
Create a Node.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(java.lang.String attrName,
boolean value)
Add an attribute for this Node.
|
void |
addAttribute(java.lang.String attrName,
float value)
Add an attribute for this Node.
|
void |
addAttribute(java.lang.String attrName,
int value)
Add an attribute for this Node.
|
void |
addAttribute(java.lang.String attrName,
java.lang.String value)
Add an attribute for this Node.
|
void |
addChild(XMLNode child)
Add a child to this Node.
|
XMLNode |
copy()
Create a copy of this node.
|
int |
countAttributes()
Return the number of attributes of the Node.
|
int |
countChildren()
Return the number of children of the Node.
|
boolean |
equals(java.lang.Object obj) |
java.util.List<XMLNode> |
getAllChildren(java.lang.String name)
Return the list of all children of this node having a specified name.
|
java.util.Map<java.lang.String,java.lang.String> |
getAttributes()
Return the Map of attributes for this node.
|
java.lang.String |
getAttributeValue(java.lang.String attrName)
Return the value of an attribute of a specified name.
|
boolean |
getAttributeValueAsBoolean(java.lang.String attrName)
Return the value of an attribute of a specified name as a boolean.
|
boolean |
getAttributeValueAsBoolean(java.lang.String attrName,
boolean defaultValue)
Return the value of an attribute of a specified name as a boolean.
|
float |
getAttributeValueAsFloat(java.lang.String attrName)
Return the value of an attribute of a specified name as a float.
|
float |
getAttributeValueAsFloat(java.lang.String attrName,
float defaultValue)
Return the value of an attribute of a specified name as a float.
|
int |
getAttributeValueAsInt(java.lang.String attrName)
Return the value of an attribute of a specified name as an int.
|
int |
getAttributeValueAsInt(java.lang.String attrName,
int defaultValue)
Return the value of an attribute of a specified name as an int.
|
java.lang.String |
getCDATA()
Return the CDATA content for the node.
|
java.util.List<XMLNode> |
getChildren()
Return the ordered list of children of this Node.
|
XMLNode |
getFirstChild()
Return the first child of the Node.
|
XMLNode |
getLastChild()
Return the last child of the Node.
|
java.lang.String |
getName()
Return the Node qualified name.
|
XMLNode |
getNextSibling()
Return the next sibling of the Node.
|
XMLNode |
getParent()
Return the Node parent (or null if the Node is the root of the XML File).
|
XMLNode |
getPreviousSibling()
Return the previous sibling of the Node.
|
boolean |
hasAttribute(java.lang.String attrName)
Return true if the Node has an attribute of a specified name.
|
boolean |
hasCDATA()
Return true if there is a the CDATA content for the node.
|
boolean |
hasChildren()
Return true if this Node has children.
|
int |
hashCode() |
void |
setCDATA(java.lang.String cData)
Set the CDATA content for the node.
|
java.lang.String |
toString() |
protected java.lang.String name
protected XMLNode nodeParent
protected final java.util.List<XMLNode> children
protected final java.util.Map<java.lang.String,java.lang.String> attributes
public XMLNode(java.lang.String nodeName)
nodeName
- the Node namepublic XMLNode(XMLNode parent, java.lang.String nodeName)
parent
- the Node parentnodeName
- the Node namepublic XMLNode copy()
public java.util.List<XMLNode> getAllChildren(java.lang.String name)
name
- the namepublic XMLNode getParent()
public java.lang.String getName()
public java.util.List<XMLNode> getChildren()
public XMLNode getFirstChild()
public XMLNode getLastChild()
public XMLNode getNextSibling()
public XMLNode getPreviousSibling()
public void addChild(XMLNode child)
child
- the Node childpublic boolean hasChildren()
public int countChildren()
public int countAttributes()
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
public java.lang.String getAttributeValue(java.lang.String attrName)
attrName
- the attribute namepublic boolean getAttributeValueAsBoolean(java.lang.String attrName)
attrName
- the attribute namepublic boolean getAttributeValueAsBoolean(java.lang.String attrName, boolean defaultValue)
attrName
- the attribute namedefaultValue
- the default valuepublic float getAttributeValueAsFloat(java.lang.String attrName)
attrName
- the attribute namepublic float getAttributeValueAsFloat(java.lang.String attrName, float defaultValue)
attrName
- the attribute namedefaultValue
- the default valuepublic int getAttributeValueAsInt(java.lang.String attrName)
attrName
- the attribute namepublic int getAttributeValueAsInt(java.lang.String attrName, int defaultValue)
attrName
- the attribute namedefaultValue
- the default valuepublic void addAttribute(java.lang.String attrName, int value)
attrName
- the attribute namevalue
- the attribute valuepublic void addAttribute(java.lang.String attrName, java.lang.String value)
attrName
- the attribute namevalue
- the attribute valuepublic void addAttribute(java.lang.String attrName, float value)
attrName
- the attribute namevalue
- the attribute valuepublic void addAttribute(java.lang.String attrName, boolean value)
attrName
- the attribute namevalue
- the attribute valuepublic void setCDATA(java.lang.String cData)
cData
- the CDATA contentpublic java.lang.String getCDATA()
public boolean hasCDATA()
public boolean hasAttribute(java.lang.String attrName)
attrName
- the attribute namepublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2021, 2022 Herve Girod. All Rights Reserved. Documentation and source under the BSD 3-Clause licence