Class NodeAddData
java.lang.Object
org.apache.commons.configuration.tree.NodeAddData
A simple data class used by ExpressionEngine
to store
the results of the prepareAdd()
operation.
If a new property is to be added to a configuration, the affected
Configuration
object must know, where in its hierarchy of
configuration nodes new elements have to be added. This information is
obtained by an ExpressionEngine
object that interprets the key
of the new property. This expression engine will pack all information
necessary for the configuration to perform the add operation in an instance
of this class.
Information managed by this class contains:
- the configuration node, to which new elements must be added
- the name of the new node
- whether the new node is a child node or an attribute node
- if a whole branch is to be added at once, the names of all nodes between the parent node (the target of the add operation) and the new node
- Since:
- 1.3
- Version:
- $Id: NodeAddData.java 1234988 2012-01-23 21:12:15Z oheger $
- Author:
- Commons Configuration team
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new, uninitialized instance ofNodeAddData
.NodeAddData
(ConfigurationNode parent, String nodeName) Creates a new instance ofNodeAddData
and sets the most important data fields. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPathNode
(String nodeName) Adds the name of a path node.Returns the name of the new node.Returns the parent node.Returns a list with further nodes that must be added.boolean
Returns a flag if the new node to be added is an attribute.void
setAttribute
(boolean attribute) Sets the attribute flag.void
setNewNodeName
(String newNodeName) Sets the name of the new node.void
setParent
(ConfigurationNode parent) Sets the parent node.
-
Constructor Details
-
NodeAddData
public NodeAddData()Creates a new, uninitialized instance ofNodeAddData
. -
NodeAddData
Creates a new instance ofNodeAddData
and sets the most important data fields.- Parameters:
parent
- the parent nodenodeName
- the name of the new node
-
-
Method Details
-
isAttribute
Returns a flag if the new node to be added is an attribute.- Returns:
- true for an attribute node, false for a child node
-
setAttribute
Sets the attribute flag. This flag determines whether an attribute or a child node will be added.- Parameters:
attribute
- the attribute flag
-
getNewNodeName
Returns the name of the new node.- Returns:
- the new node's name
-
setNewNodeName
Sets the name of the new node. A node with this name will be added to the configuration's node hierarchy.- Parameters:
newNodeName
- the name of the new node
-
getParent
Returns the parent node.- Returns:
- the parent node
-
setParent
Sets the parent node. New nodes will be added to this node.- Parameters:
parent
- the parent node
-
getPathNodes
Returns a list with further nodes that must be added. This is needed if a complete branch is to be added at once. For instance imagine that there exists only a nodedatabase
. Now the keydatabase.connection.settings.username
(assuming the syntax of the default expression engine) is to be added. Thenusername
is the name of the new node, but the nodesconnection
andsettings
must be added to the parent node first. In this example these names would be returned by this method.- Returns:
- a list with the names of nodes that must be added as parents of the new node (never null)
-
addPathNode
Adds the name of a path node. With this method an additional node to be added can be defined.- Parameters:
nodeName
- the name of the node- See Also:
-