You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2024/04/23 22:03:00 UTC
[jira] [Resolved] (CONFIGURATION-844) INIConfiguration support empty sections
[ https://issues.apache.org/jira/browse/CONFIGURATION-844?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary D. Gregory resolved CONFIGURATION-844.
-------------------------------------------
Fix Version/s: 2.10.2
Resolution: Fixed
> INIConfiguration support empty sections
> ---------------------------------------
>
> Key: CONFIGURATION-844
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-844
> Project: Commons Configuration
> Issue Type: Improvement
> Components: Expression engine
> Affects Versions: 2.10.1
> Reporter: Thomas Steiner
> Priority: Minor
> Fix For: 2.10.2
>
>
>
> ini files with empty sections are currently not supported
> Properties without a key (e.g. " = worse") can be accessed by a space key. I would suggest to also provide this feature for empty sections:
> example emptySection.ini:
> {code:java}
> []
> property = "property1"{code}
> test code:
> {code:java}
> INIConfiguration iniConfiguration = new INIConfiguration();
> try (FileReader fileReader = new FileReader("emptySection.ini")) {
> iniConfiguration.read(fileReader);
> } catch (ConfigurationException | IOException e) {
> e.printStackTrace();
> }
> SubnodeConfiguration subSection = iniConfiguration.getSection(" "); // empty section can be accessed by a space
> String nextKey = subSection.getKeys().next();
> assertNotNull(nextKey);
> assertEquals("property", nextKey);
> Object nextValue = subSection.getProperty(nextKey);
> assertNotNull(nextValue);
> assertEquals("property1", nextValue); {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)