[
https://issues.apache.org/jira/browse/CONFIGURATION-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14162895#comment-14162895
]
Ho-jin Lee commented on CONFIGURATION-427:
------------------------------------------
Of course, it's my pleasure.
My suggestion code cannot recognize String[]. But it can recognize List.
------------- Test code ---------------
package mytest;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.plist.XMLPropertyListConfiguration;
class test {
public static void main(String[] args) throws ConfigurationException {
XMLPropertyListConfiguration config = new
XMLPropertyListConfiguration();
List<String> strings = new ArrayList<String>();
strings.add("element1");
strings.add("element2");
strings.add("element3");
config.addProperty("arrayTest", strings);
StringWriter writer = new StringWriter();
try {
config.save(writer);
} catch (ConfigurationException e) {
e.printStackTrace();
}
System.out.println(writer.toString());
}
}
--------- Result ----------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>arrayTest</key>
<array>
<string>element1</string>
<string>element2</string>
<string>element3</string>
</array>
</dict>
</plist>
> XMLPropertyListConfiguration cannot save arrays in the correct plist form
> -------------------------------------------------------------------------
>
> Key: CONFIGURATION-427
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-427
> Project: Commons Configuration
> Issue Type: Bug
> Components: Format
> Affects Versions: 1.6
> Environment: should show up in any environment, as the test cases are
> disabled for arrays and maps:
> http://commons.apache.org/configuration/xref-test/org/apache/commons/configuration/plist/TestXMLPropertyListConfiguration.html#199
> I was testing 1.6 using groovy console under Mac OS X 10.6
> Reporter: matthew smith
> Assignee: Emmanuel Bourg
> Priority: Minor
> Attachments: configuration-427.patch
>
>
> {code:java}
> groovy> import org.apache.commons.configuration.plist.*
> groovy> def config = new XMLPropertyListConfiguration()
> groovy> config.addProperty("things", ['chair', 'hat', 'door'])
> groovy> config.save(System.out)
> {code}
> results in
>
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM
> "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
> <dict>
> <key>things</key>
> <string>chair</string>
> <key>things</key>
> <string>hat</string>
> <key>things</key>
> <string>door</string>
> </dict>
> </plist>
> {code}
> expecting
> {code:xml}
> <?xml version="1.0"?>
> <!DOCTYPE plist SYSTEM
> "file://localhost/System/Library/DTDs/PropertyList.dtd">
> <plist version="1.0">
> <dict>
> <key>things</key>
> <array>
> <string>chair</string>
> <string>hat</string>
> <string>door</string>
> </array>
> </dict>
> </plist>
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)