public final class JNode extends Object implements Serializable
JNode is a lightweight tree structure.| Modifier and Type | Field and Description |
|---|---|
static String |
ATT_PREFIX |
static String |
HIDE_SURFIX |
static String |
MAP_SURFIX |
static String |
NODE_DESC |
static String |
NODE_ID |
static String |
NODE_NAME |
static String |
NODE_PATH |
static String |
NODE_TYPE |
static String |
NODE_VALU |
static String |
TAG_SURFIX |
static String |
TYPE_ROOT |
| Constructor and Description |
|---|
JNode(String type)
Creates a new
JNode instance by the specified type. |
JNode(String type,
String name,
String value,
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. |
String |
getAttribute(String name)
Returns an attribute of the node with the specified attribute name.
|
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(String name)
Returns the child node with the specified node name in this node.
|
String[] |
getChildNames()
Returns all children nodes' names in a string array.
|
Iterator |
getChildren()
Returns all children
JNode in Iterator. |
String |
getDescription()
Gets the description attribute of this node.
|
String |
getID()
Returns the id of the node path.
|
String |
getName()
Returns the name of the node.
|
JNode |
getParent()
Returns the parent node of the node.
|
String |
getPath()
Returns the path of the node in the node tree.
|
static String |
getPathID(String path)
Returns the path id of the node.
|
String |
getText()
Returns the text string attached to the node.
|
String |
getType()
Returns the type of the node.
|
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(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(String name)
Removes the child node with the specified node name in this node.
|
void |
setAttribute(String name,
String value)
Sets an attribute of the node with the specified attribute name.
|
void |
setDescription(String desc)
Sets the description attribute of this node.
|
void |
setName(String name)
Sets the name attribute of this node with specified name.
|
void |
setPathPrefix(String prefix)
Sets the path prefix of the node.
|
void |
setText(String text)
Sets the text string attached to the node.
|
void |
setValue(String value)
Sets the value attribute of this node with specified value.
|
int |
size()
Returns the children size of the node.
|
static Document |
toDocument(JNode jnode,
Properties props)
Transfers a
JNode to a W3C Document. |
String |
toXML(Properties props)
Exports the node to XML string.
|
static StringBuffer |
writeXML(JNode jnode,
Properties props)
Exports a
JNode to XML in a StringBuffer. |
public static final transient String TAG_SURFIX
public static final transient String ATT_PREFIX
public static final transient String MAP_SURFIX
public static final transient String HIDE_SURFIX
public static final transient String NODE_TYPE
public static final transient String NODE_NAME
public static final transient String NODE_VALU
public static final transient String NODE_DESC
public static final transient String NODE_PATH
public static final transient String NODE_ID
public static final transient String TYPE_ROOT
public JNode(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(String type, String name, String value, 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 String getAttribute(String name)
name - the attribute name.String.public void setAttribute(String name, String value)
name - the attribute name.value - the attribute value.public Iterator getAttributeNames()
Iterator.public String getType()
public String getName()
public void setName(String name)
name - the name.public String getValue()
public void setValue(String value)
value - the value.public String getDescription()
public void setDescription(String desc)
desc - the description.public String getText()
public void setText(String text)
text - the text.public String getPath()
public void setPathPrefix(String prefix)
prefix - the path prefix.public String getID()
getPath(),
getPathID(String)public static String getPathID(String path)
path - the node path.public int size()
public 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(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(String name)
name - the specified node name.public int indexOfChild(String name)
name - the specified node name to search for.public String[] getChildNames()
public boolean isRoot()
"root".public void clear()
public int hashCode()
String 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 String toXML(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 StringBuffer writeXML(JNode jnode, Properties props)
JNode to XML in a StringBuffer.jnode - The JNode object.props - some output control parameters, @see #toXML(Properties).public static Document toDocument(JNode jnode, Properties props)
JNode to a W3C Document.jnode - The JNode object.props - some output control parameters, @see #toXML(Properties).© insightsoftware. All rights reserved.