public final class JNode
extends java.lang.Object
implements java.io.Serializable
JNode
is a lightweight tree structure.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ATT_PREFIX |
static java.lang.String |
HIDE_SURFIX |
static java.lang.String |
MAP_SURFIX |
static java.lang.String |
NODE_DESC |
static java.lang.String |
NODE_ID |
static java.lang.String |
NODE_NAME |
static java.lang.String |
NODE_PATH |
static java.lang.String |
NODE_TYPE |
static java.lang.String |
NODE_VALU |
static java.lang.String |
TAG_SURFIX |
static java.lang.String |
TYPE_ROOT |
Constructor and Description |
---|
JNode(java.lang.String type)
Creates a new
JNode instance by the specified type. |
JNode(java.lang.String type,
java.lang.String name,
java.lang.String value,
java.lang.String desc)
Creates a new
JNode instance by the specified type. |
Modifier and Type | Method and Description |
---|---|
void |
addChild(int index,
JNode node)
Inserts the specified node at the specified position in this node.
|
void |
addChild(JNode node)
Appends the specified node to the end of this node.
|
void |
clear()
Removes all of the children nodes from this node.
|
static JNode |
clone(JNode o)
Initializes a newly created
JNode object so that it represents
the same as the argument; in other words, the newly created JNode is a
copy of the argument JNode. |
java.lang.String |
getAttribute(java.lang.String name)
Returns an attribute of the node with the specified attribute name.
|
java.util.Iterator |
getAttributeNames()
Returns all attribute names in an
Iterator . |
JNode |
getChild(int index)
Returns the child node at the specified position in this node.
|
JNode |
getChild(java.lang.String name)
Returns the child node with the specified node name in this node.
|
java.lang.String[] |
getChildNames()
Returns all children nodes' names in a string array.
|
java.util.Iterator |
getChildren()
Returns all children
JNode in Iterator . |
java.lang.String |
getDescription()
Gets the description attribute of this node.
|
java.lang.String |
getID()
Returns the id of the node path.
|
java.lang.String |
getName()
Returns the name of the node.
|
JNode |
getParent()
Returns the parent node of the node.
|
java.lang.String |
getPath()
Returns the path of the node in the node tree.
|
static java.lang.String |
getPathID(java.lang.String path)
Returns the path id of the node.
|
java.lang.String |
getText()
Returns the text string attached to the node.
|
java.lang.String |
getType()
Returns the type of the node.
|
java.lang.String |
getValue()
Returns the value attribute of this node.
|
int |
hashCode()
Returns a hash code for this node.
The hash code is @see getName() String object. |
int |
indexOfChild(java.lang.String name)
Returns the index of the first occurrence of the specified child node in
this node, or -1 if this node does not contain a child node.
|
boolean |
isRoot()
Tests whether the node type is
"root" . |
JNode |
removeChild(int index)
Removes the child node at the specified position in this node.
|
JNode |
removeChild(java.lang.String name)
Removes the child node with the specified node name in this node.
|
void |
setAttribute(java.lang.String name,
java.lang.String value)
Sets an attribute of the node with the specified attribute name.
|
void |
setDescription(java.lang.String desc)
Sets the description attribute of this node.
|
void |
setName(java.lang.String name)
Sets the name attribute of this node with specified name.
|
void |
setPathPrefix(java.lang.String prefix)
Sets the path prefix of the node.
|
void |
setText(java.lang.String text)
Sets the text string attached to the node.
|
void |
setValue(java.lang.String value)
Sets the value attribute of this node with specified value.
|
int |
size()
Returns the children size of the node.
|
static org.w3c.dom.Document |
toDocument(JNode jnode,
java.util.Properties props)
Transfers a
JNode to a W3C Document . |
java.lang.String |
toXML(java.util.Properties props)
Exports the node to XML string.
|
static java.lang.StringBuffer |
writeXML(JNode jnode,
java.util.Properties props)
Exports a
JNode to XML in a StringBuffer . |
public static final transient java.lang.String TAG_SURFIX
public static final transient java.lang.String ATT_PREFIX
public static final transient java.lang.String MAP_SURFIX
public static final transient java.lang.String HIDE_SURFIX
public static final transient java.lang.String NODE_TYPE
public static final transient java.lang.String NODE_NAME
public static final transient java.lang.String NODE_VALU
public static final transient java.lang.String NODE_DESC
public static final transient java.lang.String NODE_PATH
public static final transient java.lang.String NODE_ID
public static final transient java.lang.String TYPE_ROOT
public JNode(java.lang.String type)
JNode
instance by the specified type.type
- the node type, which starts with TYPE_, and is defined in
JNode, ResourceTreeBuilder, or TOCTreeBuilder, such asJNode.TYPE_ROOT
,ResourceTreeBuilder.TYPE_DATASOURCE
,TOCTreeBuilder.TYPE_TOCNODE
.public JNode(java.lang.String type, java.lang.String name, java.lang.String value, java.lang.String desc)
JNode
instance by the specified type.type
- the node type, which starts with TYPE_, and is defined in
JNode, ResourceTreeBuilder, or TOCTreeBuilder, such asJNode.TYPE_ROOT
,ResourceTreeBuilder.TYPE_DATASOURCE
,TOCTreeBuilder.TYPE_TOCNODE
.name
- the node name.value
- the node value.desc
- the node description.public JNode getParent()
public java.lang.String getAttribute(java.lang.String name)
name
- the attribute name.String
.public void setAttribute(java.lang.String name, java.lang.String value)
name
- the attribute name.value
- the attribute value.public java.util.Iterator getAttributeNames()
Iterator
.public java.lang.String getType()
public java.lang.String getName()
public void setName(java.lang.String name)
name
- the name.public java.lang.String getValue()
public void setValue(java.lang.String value)
value
- the value.public java.lang.String getDescription()
public void setDescription(java.lang.String desc)
desc
- the description.public java.lang.String getText()
public void setText(java.lang.String text)
text
- the text.public java.lang.String getPath()
public void setPathPrefix(java.lang.String prefix)
prefix
- the path prefix.public java.lang.String getID()
getPath()
,
getPathID(String)
public static java.lang.String getPathID(java.lang.String path)
path
- the node path.public int size()
public java.util.Iterator getChildren()
JNode
in Iterator
.public void addChild(JNode node)
node
- the node to be appended to this node.public void addChild(int index, JNode node)
index
- index at which the specified node is to be inserted.node
- the node to be inserted.public JNode getChild(int index)
index
- index of the child node to return.JNode
the child node at the specified position in
this node.public JNode getChild(java.lang.String name)
name
- the specified node name.JNode
the child node at the specified position in
this nod.public JNode removeChild(int index)
index
- the index of the child node to be removed.public JNode removeChild(java.lang.String name)
name
- the specified node name.public int indexOfChild(java.lang.String name)
name
- the specified node name to search for.public java.lang.String[] getChildNames()
public boolean isRoot()
"root"
.public void clear()
public int hashCode()
String
object.hashCode
in class java.lang.Object
public static JNode clone(JNode o)
JNode
object so that it represents
the same as the argument; in other words, the newly created JNode is a
copy of the argument JNode.o
- a JNode
.public java.lang.String toXML(java.util.Properties props)
props
- some output control parameters, for example,
"xml.encoding"
for writing the
Document
to a file, if the default value is not
"UTF-8". "xml.indent"
is used to control
whether to indent according to the nodes hierarchy when
output, if the default value is not "false".
public static java.lang.StringBuffer writeXML(JNode jnode, java.util.Properties props)
JNode
to XML in a StringBuffer
.jnode
- The JNode
object.props
- some output control parameters, @see #toXML(Properties).public static org.w3c.dom.Document toDocument(JNode jnode, java.util.Properties props)
JNode
to a W3C Document
.jnode
- The JNode
object.props
- some output control parameters, @see #toXML(Properties).