You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by eb...@apache.org on 2004/10/04 21:35:45 UTC
cvs commit: jakarta-commons/configuration/xdocs changes.xml
ebourg 2004/10/04 12:35:45
Modified: configuration/src/java/org/apache/commons/configuration
XMLConfiguration.java
configuration/xdocs changes.xml
Log:
Fixed bug Bug 30799, thanks to Rory Winston for spotting the source of the issue !
Revision Changes Path
1.17 +13 -74 jakarta-commons/configuration/src/java/org/apache/commons/configuration/XMLConfiguration.java
Index: XMLConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/XMLConfiguration.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XMLConfiguration.java 26 Sep 2004 16:29:24 -0000 1.16
+++ XMLConfiguration.java 4 Oct 2004 19:35:45 -0000 1.17
@@ -167,9 +167,7 @@
/**
* Loads and initializes from the XML file.
*
- * @param element
- * The element to start processing from. Callers should supply
- * the root element of the document.
+ * @param element The element to start processing from. Callers should supply the root element of the document.
* @param hierarchy
*/
private void initProperties(Element element, StringBuffer hierarchy)
@@ -206,10 +204,8 @@
* Helper method for constructing properties for the attributes of the given
* XML element.
*
- * @param hierarchy
- * the actual hierarchy
- * @param element
- * the actual XML element
+ * @param hierarchy the actual hierarchy
+ * @param element the actual XML element
*/
private void processAttributes(String hierarchy, Element element)
{
@@ -237,7 +233,7 @@
possiblySave();
}
- public Object getXmlProperty(String name)
+ Object getXmlProperty(String name)
{
// parse the key
String[] nodes = parseElementNames(name);
@@ -357,60 +353,6 @@
// return text value
return StringUtils.trimToNull(str.toString());
- } // getChildText(Node):String
-
- /**
- * Calls super method, and also ensures the underlying {@linkDocument} is
- * modified so changes are persisted when saved.
- *
- * @param name
- * @param value
- */
- public void setProperty(String name, Object value)
- {
- super.setProperty(name, value);
- setXmlProperty(name, value);
- possiblySave();
- }
-
- /**
- * Sets the property value in our document tree, auto-saving if appropriate.
- *
- * @param name
- * The name of the element to set a value for.
- * @param value
- * The value to set.
- */
- private void setXmlProperty(String name, Object value)
- {
- // parse the key
- String[] nodes = parseElementNames(name);
- String attName = parseAttributeName(name);
-
- Element element = document.getDocumentElement();
- for (int i = 0; i < nodes.length; i++)
- {
- String eName = nodes[i];
- Element child = getChildElementWithName(eName, element);
- // If we don't find this part of the property in the XML hierarchy
- // we add it as a new node
- if (child == null)
- {
- child = document.createElement(eName);
- element.appendChild(child);
- }
- element = child;
- }
-
- if (attName == null)
- {
- CharacterData data = document.createTextNode(String.valueOf(value));
- element.appendChild(data);
- }
- else
- {
- element.setAttribute(attName, String.valueOf(value));
- }
}
private Element getChildElementWithName(String eName, Element element)
@@ -435,12 +377,10 @@
}
/**
- * Adds the property value in our document tree, auto-saving if appropriate.
+ * Adds the property value in our document tree.
*
- * @param name
- * The name of the element to set a value for.
- * @param value
- * The value to set.
+ * @param name The name of the element to set a value for.
+ * @param value The value to set.
*/
private void addXmlProperty(String name, Object value)
{
@@ -454,7 +394,9 @@
for (int i = 0; i < nodes.length; i++)
{
if (element == null)
+ {
break;
+ }
parent = element;
String eName = nodes[i];
Element child = getChildElementWithName(eName, element);
@@ -479,8 +421,7 @@
* Calls super method, and also ensures the underlying {@link Document}is
* modified so changes are persisted when saved.
*
- * @param name
- * The name of the property to clear.
+ * @param name The name of the property to clear.
*/
public void clearProperty(String name)
{
@@ -620,8 +561,7 @@
* Parse a property key and return an array of the element hierarchy it
* specifies. For example the key "x.y.z[@abc]" will result in [x, y, z].
*
- * @param key
- * the key to parse
+ * @param key the key to parse
*
* @return the elements in the key
*/
@@ -649,8 +589,7 @@
/**
* Parse a property key and return the attribute name if it existst.
*
- * @param key
- * the key to parse
+ * @param key the key to parse
*
* @return the attribute name, or null if the key doesn't contain one
*/
1.49 +5 -0 jakarta-commons/configuration/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- changes.xml 24 Sep 2004 20:52:57 -0000 1.48
+++ changes.xml 4 Oct 2004 19:35:45 -0000 1.49
@@ -7,7 +7,12 @@
<body>
<release version="1.0" date="IN CVS">
+ <action dev="ebourg" type="fix" issue="30799">
+ Properties added to an XMLConfiguration are no longer duplicated in the
+ resulting XML file.
+ </action>
</release>
+
<release version="1.0-rc2" date="2004-09-24">
<action dev="ebourg" type="update">
Unified the mechanisms for loading and saving file based configurations.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org