|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.moremotion.adom.ADOMNode
public class ADOMNode
Represents a single node in ADOM (Application Data Object Model).
Each node has a name, a value which can be set and used as String, Integer, Double
and boolean
.
Each node can have a set of attributes and a set of child nodes.
Since ADOMs and ADOMNodes are used in XML content generation, a node corresponds to an XML tag. Considering this, the node names should accord to the rules of naming XML tags.
Field Summary | |
---|---|
static byte |
DT_BOOL
|
static byte |
DT_INTEGER
|
static byte |
DT_NUMBER
|
static byte |
DT_STRING
|
Constructor Summary | |
---|---|
ADOMNode(java.lang.String name)
Creates a new ADOMNode and names it. |
|
ADOMNode(java.lang.String name,
java.lang.String value)
Creates a new ADOMNode, names it and sets its value. |
Method Summary | |
---|---|
java.lang.String |
addAttribute(java.lang.String name,
java.lang.String value)
Adds a new node attribute to this node. |
void |
addNode(ADOMNode node)
Adds the given node under this node. |
void |
clear()
Removes all the child nodes of this node |
java.lang.Object |
clone()
|
boolean |
equals(java.lang.Object obj)
Checks the equality of this node to another node with all their content. |
ADOMNode |
findNode(java.lang.String nodePath)
Finds the node by the given node path and returns it. |
java.lang.String |
getAttribute(java.lang.String name)
Returns the value of a node attribute. |
int |
getAttributeCount()
Returns the number of attributes that this node has. |
java.util.Properties |
getAttributes()
Returns the attributes of this node as a Properties object. |
java.lang.String |
getName()
Returns the name of this node. |
ADOMNode |
getNode(java.lang.String nodePath)
Finds the node by the given node path and returns it. |
int |
getNodeCount()
Returns the number of the child nodes of this node. |
java.util.Iterator |
getNodes()
Returns an Iterator interface for the first level child nodes of this node. |
ADOMNode[] |
getNodesArray()
Returns an ADOMNode array from the first level child nodes of this node. |
java.lang.String |
getNodeValue(java.lang.String nodePath)
Finds the node by the given node path and returns its value. |
java.util.Properties |
getNodeValues()
Returns the values of the first level child nodes in a Properties object. |
ADOMNode |
getParent()
Returns the parent node of this node. |
java.lang.String |
getPath()
Returns the path of this node starting form the root node. |
ADOMNode |
getRootNode()
Returns the root node |
ADOMNode |
getSubNode(java.lang.String name)
|
java.lang.String |
getValue()
Returns the value of this node as String. |
boolean |
getValueAsBoolean()
Returns the value of this node as boolean . |
double |
getValueAsDouble()
Return the value of the node as double . |
int |
getValueAsInt()
Return the value of the node as int . |
java.lang.Object |
getValueAsObject()
Returns the value of this node as Object . |
java.lang.String |
getValueAsString()
Return the value of the node as String . |
java.lang.String |
getValueForXML()
Returns the value of this node to build XML content. |
boolean |
hasChild(java.lang.String nodeName)
Checks if this node has a child node with the given node name. |
boolean |
isRoot()
Returns true if this node is the root node of the ADOM, false otherwise. |
static void |
main(java.lang.String[] args)
Test method. |
java.lang.String |
removeAttribute(java.lang.String name)
Removes a node attribute from this node by its name. |
void |
removeLast()
|
boolean |
removeNode(ADOMNode node)
Removes the given child node. |
void |
setName(java.lang.String value)
Sets the name of this node. |
ADOMNode |
setNodeValue(java.lang.String nodePath,
java.lang.String value)
Finds the node by the given node path and sets its value. |
void |
setNodeValues(java.util.Properties props)
Sets the values of the child nodes using a Properties object. |
void |
setParent(ADOMNode value)
Sets the parent node of this node. |
void |
setValue(boolean value)
Sets value of this node as Boolean object |
void |
setValue(double value)
Sets value of this node as double . |
void |
setValue(int value)
Sets value of this node as Integer object |
void |
setValue(java.lang.Object value)
Sets value object of this node |
void |
sort(java.lang.String sortDefinition)
|
java.lang.String |
toString()
Returns the string representation of this node. |
java.lang.String |
toXml()
Converts this node and all its child nodes to XML string. |
java.lang.String |
toXml(java.lang.String tagName)
Converts this node and all its child nodes to XML string. |
java.lang.String |
toXmlWithIndent()
Converts this node and all its child nodes to XML string. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final byte DT_STRING
public static final byte DT_NUMBER
public static final byte DT_BOOL
public static final byte DT_INTEGER
Constructor Detail |
---|
public ADOMNode(java.lang.String name)
name
- Node name.public ADOMNode(java.lang.String name, java.lang.String value)
name
- Node name.value
- Node value.Method Detail |
---|
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public java.lang.String getName()
public void setName(java.lang.String value)
value
- New name of this node.public java.lang.String getValue()
public java.lang.String getValueForXML()
Note that some nodes can contain secret information which should not be included in XML in clear format.
{HIDDEN_VALUE}
if the value of this node is a HiddenStringpublic void setValue(java.lang.Object value)
value
- Value to be set.public void setValue(double value)
double
.
value
- double
value.public void setValue(int value)
Integer
object
value
- int
value.public void setValue(boolean value)
Boolean
object
value
- boolean
value.public java.lang.Object getValueAsObject()
Object
.
public java.lang.String getValueAsString()
String
.
public int getValueAsInt()
int
. If the value of the node cannot be converted
to integer '0' is returned.
public double getValueAsDouble()
double
. If the value of the node cannot be converted
to a number, '0' is returned.
public boolean getValueAsBoolean()
boolean
. Returns false
if the value of the node cannot be converted
to boolean.
public boolean isRoot()
true
if this node is the root node of the ADOM, false
otherwise.
public ADOMNode getParent()
null
if this node is the root node, otherwise the parent node.public void setParent(ADOMNode value)
public ADOMNode getRootNode()
public java.lang.String getPath()
public java.lang.String addAttribute(java.lang.String name, java.lang.String value)
name
- Name of the attributevalue
- Value of the attribute
null
if the attribute does not already exists, its value Otherwise.public java.lang.String removeAttribute(java.lang.String name)
name
- Name of the attribute.
null
value is returned.public java.lang.String getAttribute(java.lang.String name)
name
- Name of the attribute.
null
if attribute does not exist.public java.util.Properties getAttributes()
Properties
object.
public int getAttributeCount()
public void addNode(ADOMNode node)
public boolean removeNode(ADOMNode node)
public void removeLast()
public java.util.Iterator getNodes()
Iterator
interface for the first level child nodes of this node.
public ADOMNode[] getNodesArray()
ADOMNode
array from the first level child nodes of this node. If this node has no
children then returns an empty array (zero-length).
public ADOMNode getNode(java.lang.String nodePath)
Note that the nodes that do not exist in the node path are created
public ADOMNode findNode(java.lang.String nodePath)
null
if the node is not found.public boolean hasChild(java.lang.String nodeName)
nodeName
- Name of the child.
true
if the child node exists, false
otherwise.public ADOMNode getSubNode(java.lang.String name)
public java.lang.String getNodeValue(java.lang.String nodePath)
public java.util.Properties getNodeValues()
Properties
object.
public ADOMNode setNodeValue(java.lang.String nodePath, java.lang.String value)
Note that the nodes that do not exist in the node path are created.
nodePath
- Path name.value
- Value to set.
public void setNodeValues(java.util.Properties props)
Properties
object.
The keys of the Properties object are used as node paths which define the nodes to be modified and the values
are used as the values of the nodes.
props
- Properties object that contains Node path/Value pairs.public int getNodeCount()
public void clear()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public void sort(java.lang.String sortDefinition)
public java.lang.String toXml()
public java.lang.String toXml(java.lang.String tagName)
tagName
- The name of the XML tag.
If parameter is null then no tag will be included in the XML.public java.lang.String toXmlWithIndent()
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |