Bug 104047 [Dialogs] Incorrect Output from DialogSettings.save()
The XML produced by the DialogSettings.save() method is not correct. If multiple arrayItems exist, every element after the first will have an extra "value" attribute. Here is a code snipet to illustrate: IDialogSettings export = new DialogSettings("Example"); String[] values1 = { "value1", "value2" }; export.put("key1", values1 ); String[] values2 = { "value3", "value4" }; export.put("key2", values2 ); try { export.save("C:\\test.xml"); } catch (IOException e) { // Do Nothing } The output of this is: <?xml version="1.0" encoding="UTF-8"?> <section name="Example"> <list key="key1"> <item value="value1"/> <item value="value2"/> </list> <list key="key2" value="value2"> <item value="value3"/> <item value="value4"/> </list> </section> As you can see, the second "list" has an attribute "value" which it shouldn't. The reason is the value from the previous list element is not cleared before writing the second element. I.E. "value2" from the first list element is used as the value attribute for the second list element. Suggested fix: In DialogSettings.save(), add another "attributes.clear();" for the loop that iterates over the aarryItems field.
bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/DialogSettings.java
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
 * Concrete implementation of a dialog settings (<code>IDialogSettings</code>)
 * using a hash table and XML. The dialog store can be read
 * from and saved to a stream. All keys and values must be strings or array of
 * strings. Primitive types are converted to strings.
 * <p>
 * This class was not designed to be subclassed.
 *
 * Here is an example of using a DialogSettings:
 * </p>