[jira] [Created] (CONFIGURATION-735) XML <result>/<listDelimiterHandler> configuration doesn't work

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (CONFIGURATION-735) XML <result>/<listDelimiterHandler> configuration doesn't work

JIRA jira@apache.org
Hao Chen created CONFIGURATION-735:
--------------------------------------

             Summary: XML <result>/<listDelimiterHandler> configuration doesn't work
                 Key: CONFIGURATION-735
                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-735
             Project: Commons Configuration
          Issue Type: Bug
            Reporter: Hao Chen


According to example on [https://commons.apache.org/proper/commons-configuration/userguide/howto_combinedbuilder.html]

The following xml configuration to set DefaultListDelimiterHandler should work:

<configuration>
  <header>
    <result throwExceptionOnMissing="true">
       <listDelimiterHandler config-class="org.apache.commons.configuration2.convert.DefaultListDelimiterHandler">
        <config-constrarg config-value=","/>
      </listDelimiterHandler>
    </result>
  </header>
  <override>
    <xml fileName="configuration-1.xml" reloadingRefreshDelay="10000" config-name="config3" config-optional="false" throwExceptionOnMissing="false"/>
  </override>
 </configuration>

configuration-1.xml:

<configuration>
  <header>
    <result throwExceptionOnMissing="true">
      <listDelimiterHandler config-class="org.apache.commons.configuration2.convert.DefaultListDelimiterHandler">
        <config-constrarg config-value=","/>
      </listDelimiterHandler>
    </result>
  </header>
    <apples>macintosh,delicious</apples>
 </configuration>

And get the configuration using:

            Parameters params = new Parameters();
            ReloadingCombinedConfigurationBuilder builder = new ReloadingCombinedConfigurationBuilder();
            builder.configure(params.fileBased().setFile(file));
            CombinedConfiguration configuration = builder.getConfiguration();

            List<String> apples = (List<String>) configuration.getList(String.class, "apples");

But the apples list contains only a single string:  "macintosh,delicious".... unless I programmatically set the DefaultListDelimiterHandler using:

builder.configure(params.fileBased().setFile(file).setListDelimiterHandler(new DefaultListDelimiterHandler(',')));

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)