You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2008/04/15 22:26:24 UTC
svn commit: r648405 -
/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/AbstractHierarchicalConfiguration.java
Author: oheger
Date: Tue Apr 15 13:26:23 2008
New Revision: 648405
URL: http://svn.apache.org/viewvc?rev=648405&view=rev
Log:
Extracted addNodeValue() method from processNodeAddData(), so that it can be easier overridden in sub classes
Modified:
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/AbstractHierarchicalConfiguration.java
Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/AbstractHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/AbstractHierarchicalConfiguration.java?rev=648405&r1=648404&r2=648405&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/AbstractHierarchicalConfiguration.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/AbstractHierarchicalConfiguration.java Tue Apr 15 13:26:23 2008
@@ -731,15 +731,33 @@
}
// Add the new property
- if (data.isAttribute())
+ return addNodeValue(node, data.getNewNodeName(), value, data.isAttribute());
+ }
+
+ /**
+ * Adds a new value to a node, which can either be a child node or an
+ * attribute. This method is called by <code>processNodeAddData()</code>
+ * for the final node to be added. It can be overridden by concrete sub
+ * classes with specific requirements for adding values. This base
+ * implementation uses the <code>NodeHandler</code> of this configuration
+ * for either adding a new child node or an attribute value.
+ *
+ * @param parent the parent node (to which a value should be added)
+ * @param name the name of the property to be added
+ * @param value the value itself
+ * @param attr a flag whether a child node or an attribute should be added
+ * @return the newly created child node or <b>null</b> for an attribute
+ */
+ protected T addNodeValue(T parent, String name, Object value, boolean attr)
+ {
+ if (attr)
{
- getNodeHandler().addAttributeValue(node, data.getNewNodeName(),
- value);
+ getNodeHandler().addAttributeValue(parent, name, value);
return null;
}
else
{
- T child = createNode(node, data.getNewNodeName());
+ T child = createNode(parent, name);
getNodeHandler().setValue(child, value);
return child;
}