public class JNode
extends java.lang.Object
Node
elements. This class integrates Java 5
functionality with generics.Modifier and Type | Field and Description |
---|---|
protected org.w3c.dom.Node |
node |
Constructor and Description |
---|
JNode(org.w3c.dom.Document document,
java.lang.String name)
Constructs a new
JNode for a Document . |
JNode(org.w3c.dom.Node node)
Creates a Wrapper
JNode for a Node element. |
Modifier and Type | Method and Description |
---|---|
JNode |
appendChild(JNode jNode)
Append a
JNode . |
JNode |
appendChild(org.w3c.dom.Node node)
Append an XML
Node . |
JNode |
appendChild(java.lang.String name)
Append a new
JNode with a given name. |
java.lang.String |
getAttribute(java.lang.String attribute)
Returns the value of an attribute.
|
java.util.Map<java.lang.String,java.lang.String> |
getAttributes()
Returns a
Map of all attributes. |
JNode |
getChild()
Returns the first child.
|
JNode |
getChild(java.lang.String name)
Returns the first child with a specified name.
|
java.util.List<JNode> |
getChildren()
Returns all children.
|
java.util.List<JNode> |
getChildren(java.lang.String name)
Returns all children with a specified name.
|
org.w3c.dom.Document |
getDocument()
Returns the owner
Document . |
java.lang.String |
getName()
Returns the name.
|
org.w3c.dom.Node |
getNode()
Retrieves the
Node element. |
java.lang.String |
getText()
Returns the strings content.
|
boolean |
hasAttribute(java.lang.String attribute)
Returns
true if the attribute is existent. |
boolean |
hasText()
Returns
true if this node has a strings content. |
void |
setAttribute(java.lang.String attribute,
java.lang.String value)
Sets an attribute to a value.
|
void |
setText(java.lang.String text)
Sets the strings content.
|
java.lang.String |
toString() |
public JNode(org.w3c.dom.Node node)
JNode
for a Node
element.node
- the node to wrappublic JNode(org.w3c.dom.Document document, java.lang.String name)
JNode
for a Document
.document
- the XML documentname
- the specified name of the nodepublic org.w3c.dom.Node getNode()
Node
element.public java.lang.String getName()
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
Map
of all attributes.public java.lang.String getAttribute(java.lang.String attribute)
attribute
- the name of the attributesetAttribute(java.lang.String, java.lang.String)
public boolean hasAttribute(java.lang.String attribute)
true
if the attribute is existent.attribute
- the name of the attributepublic JNode getChild()
public JNode getChild(java.lang.String name)
name
- the name of the childpublic java.util.List<JNode> getChildren()
public java.util.List<JNode> getChildren(java.lang.String name)
name
- the name of the childrenpublic java.lang.String getText()
setText(java.lang.String)
public boolean hasText()
true
if this node has a strings content.true
if this node has a strings contentpublic void setText(java.lang.String text)
text
- the strings content to setgetText()
public void setAttribute(java.lang.String attribute, java.lang.String value)
attribute
- the name of the attributevalue
- the valuegetAttribute(java.lang.String)
public JNode appendChild(java.lang.String name)
JNode
with a given name.name
- the specified namepublic JNode appendChild(org.w3c.dom.Node node)
Node
.node
- the XML nodepublic JNode appendChild(JNode jNode)
JNode
.jNode
- the node to appendpublic org.w3c.dom.Document getDocument()
Document
.public java.lang.String toString()
toString
in class java.lang.Object