Package org.opt4j.core.config
Class JNode
- java.lang.Object
-
- org.opt4j.core.config.JNode
-
public class JNode extends java.lang.Object
Wrapper forNode
elements. This class integrates Java 5 functionality with generics.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.w3c.dom.Node
node
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JNode
appendChild(java.lang.String name)
Append a newJNode
with a given name.JNode
appendChild(JNode jNode)
Append aJNode
.JNode
appendChild(org.w3c.dom.Node node)
Append an XMLNode
.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 aMap
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 ownerDocument
.java.lang.String
getName()
Returns the name.org.w3c.dom.Node
getNode()
Retrieves theNode
element.java.lang.String
getText()
Returns the strings content.boolean
hasAttribute(java.lang.String attribute)
Returnstrue
if the attribute is existent.boolean
hasText()
Returnstrue
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()
-
-
-
Constructor Detail
-
JNode
public JNode(org.w3c.dom.Node node)
Creates a WrapperJNode
for aNode
element.- Parameters:
node
- the node to wrap
-
JNode
public JNode(org.w3c.dom.Document document, java.lang.String name)
Constructs a newJNode
for aDocument
.- Parameters:
document
- the XML documentname
- the specified name of the node
-
-
Method Detail
-
getNode
public org.w3c.dom.Node getNode()
Retrieves theNode
element.- Returns:
- the XML node
-
getName
public java.lang.String getName()
Returns the name.- Returns:
- the name
-
getAttributes
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
Returns aMap
of all attributes.- Returns:
- a map of all attributes
-
getAttribute
public java.lang.String getAttribute(java.lang.String attribute)
Returns the value of an attribute.- Parameters:
attribute
- the name of the attribute- Returns:
- the value of the attribute
- See Also:
setAttribute(java.lang.String, java.lang.String)
-
hasAttribute
public boolean hasAttribute(java.lang.String attribute)
Returnstrue
if the attribute is existent.- Parameters:
attribute
- the name of the attribute- Returns:
- the value of the attribute
-
getChild
public JNode getChild()
Returns the first child.- Returns:
- the first child
-
getChild
public JNode getChild(java.lang.String name)
Returns the first child with a specified name.- Parameters:
name
- the name of the child- Returns:
- the first child with the specified name
-
getChildren
public java.util.List<JNode> getChildren()
Returns all children.- Returns:
- a list of all children.
-
getChildren
public java.util.List<JNode> getChildren(java.lang.String name)
Returns all children with a specified name.- Parameters:
name
- the name of the children- Returns:
- a list of all children with the specified name
-
getText
public java.lang.String getText()
Returns the strings content.- Returns:
- the strings content
- See Also:
setText(java.lang.String)
-
hasText
public boolean hasText()
Returnstrue
if this node has a strings content.- Returns:
true
if this node has a strings content
-
setText
public void setText(java.lang.String text)
Sets the strings content.- Parameters:
text
- the strings content to set- See Also:
getText()
-
setAttribute
public void setAttribute(java.lang.String attribute, java.lang.String value)
Sets an attribute to a value.- Parameters:
attribute
- the name of the attributevalue
- the value- See Also:
getAttribute(java.lang.String)
-
appendChild
public JNode appendChild(java.lang.String name)
Append a newJNode
with a given name.- Parameters:
name
- the specified name- Returns:
- the appended JNode
-
appendChild
public JNode appendChild(org.w3c.dom.Node node)
Append an XMLNode
.- Parameters:
node
- the XML node- Returns:
- the appended JNode
-
appendChild
public JNode appendChild(JNode jNode)
Append aJNode
.- Parameters:
jNode
- the node to append- Returns:
- the appended JNode
-
getDocument
public org.w3c.dom.Document getDocument()
Returns the ownerDocument
.- Returns:
- the owner XML document
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-