Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-187

[configuration] Add save() method and comment handling to HierarchicalXMLConfiguration

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      With this patch new save() methods are added to HierarchicalXMLConfiguration,
      which allow to save XML documents into a specified File or Writer.

      Further comments are now handled, i.e. they are read from the source file,
      stored in the internal node structure and are written to file in the save() method.

      I still hope that HierarchicalXMLConfiguration can once replace
      XMLConfiguration. This patch should be a step forward in this direction. What is
      missing are processing instructions and comments that appear before the root
      element in the XML file; these get lost.

      Oliver

        Activity

        Hide
        Oliver Heger added a comment -

        Created an attachment (id=12675)
        The diff to the actual CVS version

        Show
        Oliver Heger added a comment - Created an attachment (id=12675) The diff to the actual CVS version
        Hide
        Emmanuel Bourg added a comment -

        With this patch a comment is a property of an existing Node, or a type of Node ?

        Show
        Emmanuel Bourg added a comment - With this patch a comment is a property of an existing Node, or a type of Node ?
        Hide
        Oliver Heger added a comment -

        A comment is a property of a node. This is less flexible, but introducing a new
        node type would have an impact on other areas, e.g property lookups.

        I wonder how far our support for comments should go. I think the typical use
        case will be to ignore them and just look up properties. When storing
        configuration files it might be useful if comments can be set for certain
        properties. But I can't imagine that full support, i.e. allowing to specify
        exactly where in the configuration file a comment should be placed, is really
        necessary.

        Show
        Oliver Heger added a comment - A comment is a property of a node. This is less flexible, but introducing a new node type would have an impact on other areas, e.g property lookups. I wonder how far our support for comments should go. I think the typical use case will be to ignore them and just look up properties. When storing configuration files it might be useful if comments can be set for certain properties. But I can't imagine that full support, i.e. allowing to specify exactly where in the configuration file a comment should be placed, is really necessary.
        Hide
        David Eric Pugh added a comment -

        Hey, I looked at applying this, but couldn't get the
        TestHierarchicalConfiguration part to apply cleanly.. could you double check
        it's up to date with the latest and great and resubmit?

        Eric

        Show
        David Eric Pugh added a comment - Hey, I looked at applying this, but couldn't get the TestHierarchicalConfiguration part to apply cleanly.. could you double check it's up to date with the latest and great and resubmit? Eric
        Hide
        Oliver Heger added a comment -

        Created an attachment (id=12695)
        Patch recreated, hope it works now!

        Show
        Oliver Heger added a comment - Created an attachment (id=12695) Patch recreated, hope it works now!
        Hide
        Oliver Heger added a comment -

        After Emmanuel's refactoring of the load() and save() methods I recreated this
        patch again. I hope it can make it in the 1.0 release. This would be better than
        throwing an UnsupportedOperationException in the save() method

        Oliver

        Show
        Oliver Heger added a comment - After Emmanuel's refactoring of the load() and save() methods I recreated this patch again. I hope it can make it in the 1.0 release. This would be better than throwing an UnsupportedOperationException in the save() method Oliver
        Hide
        Oliver Heger added a comment -

        Created an attachment (id=12865)
        The new patch (valid after refactoring of load() and save() methods)

        Show
        Oliver Heger added a comment - Created an attachment (id=12865) The new patch (valid after refactoring of load() and save() methods)
        Hide
        Emmanuel Bourg added a comment -
            • COM-1726 has been marked as a duplicate of this bug. ***
        Show
        Emmanuel Bourg added a comment - COM-1726 has been marked as a duplicate of this bug. ***
        Hide
        Oliver Heger added a comment -

        A save() method was added to HierarchicalXMLConfiguration.

        I think the comment handling stuff needs some more discussion. What do we want,
        how far should we go?

        Show
        Oliver Heger added a comment - A save() method was added to HierarchicalXMLConfiguration. I think the comment handling stuff needs some more discussion. What do we want, how far should we go?
        Hide
        Oliver Heger added a comment -

        This is now fully solved by the merge of the two XML related configuration
        classes. The new XMLConfiguration class (which replaces
        HierarchicalXMLConfiguration) preserves at saving as much of the source document
        as possible, including comments and processing instructions.

        Show
        Oliver Heger added a comment - This is now fully solved by the merge of the two XML related configuration classes. The new XMLConfiguration class (which replaces HierarchicalXMLConfiguration) preserves at saving as much of the source document as possible, including comments and processing instructions.

          People

          • Assignee:
            Unassigned
            Reporter:
            Oliver Heger
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development