org.apache.commons.configuration.tree

Class NodeAddData

public class NodeAddData extends Object

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:

Since: 1.3

Author: Oliver Heger

Field Summary
booleanattribute
Stores the attribute flag.
StringnewNodeName
Stores the name of the new node.
ConfigurationNodeparent
Stores the parent node of the add operation.
ListpathNodes
Stores a list with nodes that are on the path between the parent node and the new node.
Constructor Summary
NodeAddData()
Creates a new, uninitialized instance of NodeAddData.
NodeAddData(ConfigurationNode parent, String nodeName)
Creates a new instance of NodeAddData and sets the most important data fields.
Method Summary
voidaddPathNode(String nodeName)
Adds the name of a path node.
StringgetNewNodeName()
Returns the name of the new node.
ConfigurationNodegetParent()
Returns the parent node.
ListgetPathNodes()
Returns a list with further nodes that must be added.
booleanisAttribute()
Returns a flag if the new node to be added is an attribute.
voidsetAttribute(boolean attribute)
Sets the attribute flag.
voidsetNewNodeName(String newNodeName)
Sets the name of the new node.
voidsetParent(ConfigurationNode parent)
Sets the parent node.

Field Detail

attribute

private boolean attribute
Stores the attribute flag.

newNodeName

private String newNodeName
Stores the name of the new node.

parent

private ConfigurationNode parent
Stores the parent node of the add operation.

pathNodes

private List pathNodes
Stores a list with nodes that are on the path between the parent node and the new node.

Constructor Detail

NodeAddData

public NodeAddData()
Creates a new, uninitialized instance of NodeAddData.

NodeAddData

public NodeAddData(ConfigurationNode parent, String nodeName)
Creates a new instance of NodeAddData and sets the most important data fields.

Parameters: parent the parent node nodeName the name of the new node

Method Detail

addPathNode

public void addPathNode(String nodeName)
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: getPathNodes

getNewNodeName

public String getNewNodeName()
Returns the name of the new node.

Returns: the new node's name

getParent

public ConfigurationNode getParent()
Returns the parent node.

Returns: the parent node

getPathNodes

public List 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 node database. Now the key database.connection.settings.username (assuming the syntax of the default expression engine) is to be added. Then username is the name of the new node, but the nodes connection and settings 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)

isAttribute

public boolean 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

public void setAttribute(boolean attribute)
Sets the attribute flag. This flag determines whether an attribute or a child node will be added.

Parameters: attribute the attribute flag

setNewNodeName

public void setNewNodeName(String newNodeName)
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

setParent

public void setParent(ConfigurationNode parent)
Sets the parent node. New nodes will be added to this node.

Parameters: parent the parent node