Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-844

INIConfiguration support empty sections

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.10.1
    • 2.11.0
    • Expression engine
    • None

    Description

       

      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:

      []
      property = "property1"

      test code:

      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);  

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              steinerthomas Thomas Steiner
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: