Class NodeAddData<T>
- java.lang.Object
-
- org.apache.commons.configuration2.tree.NodeAddData<T>
-
- Type Parameters:
T
- the type of nodes this class can handle
public class NodeAddData<T> extends java.lang.Object
A simple data class used by
ExpressionEngine
to store the results of theprepareAdd()
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 anExpressionEngine
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
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
attribute
Stores the attribute flag.private java.lang.String
newNodeName
Stores the name of the new node.private T
parent
Stores the parent node of the add operation.private java.util.List<java.lang.String>
pathNodes
Stores a list with the names of nodes that are on the path between the parent node and the new node.
-
Constructor Summary
Constructors Constructor Description NodeAddData(T parentNode, java.lang.String newName, boolean isAttr, java.util.Collection<java.lang.String> intermediateNodes)
Creates a new instance ofNodeAddData
and initializes it.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.List<java.lang.String>
createPathNodes(java.util.Collection<java.lang.String> intermediateNodes)
Creates the list with path nodes.java.lang.String
getNewNodeName()
Gets the name of the new node.T
getParent()
Gets the parent node.java.util.List<java.lang.String>
getPathNodes()
Gets a list with further nodes that must be added.boolean
isAttribute()
Returns a flag if the new node to be added is an attribute.
-
-
-
Field Detail
-
parent
private final T parent
Stores the parent node of the add operation.
-
pathNodes
private final java.util.List<java.lang.String> pathNodes
Stores a list with the names of nodes that are on the path between the parent node and the new node.
-
newNodeName
private final java.lang.String newNodeName
Stores the name of the new node.
-
attribute
private final boolean attribute
Stores the attribute flag.
-
-
Constructor Detail
-
NodeAddData
public NodeAddData(T parentNode, java.lang.String newName, boolean isAttr, java.util.Collection<java.lang.String> intermediateNodes)
Creates a new instance ofNodeAddData
and initializes it.- Parameters:
parentNode
- the parent node of the add operationnewName
- the name of the new nodeisAttr
- flag whether the new node is an attributeintermediateNodes
- an optional collection with path nodes
-
-
Method Detail
-
createPathNodes
private static java.util.List<java.lang.String> createPathNodes(java.util.Collection<java.lang.String> intermediateNodes)
Creates the list with path nodes. Handles null input.- Parameters:
intermediateNodes
- the nodes passed to the constructor- Returns:
- an unmodifiable list of path nodes
-
getNewNodeName
public java.lang.String getNewNodeName()
Gets the name of the new node.- Returns:
- the new node's name
-
getParent
public T getParent()
Gets the parent node.- Returns:
- the parent node
-
getPathNodes
public java.util.List<java.lang.String> getPathNodes()
Gets 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)
-
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
-
-