commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 39182] - [configuration] Preserve file structure (line comments) when re-saving properties file
Date Tue, 11 Apr 2006 17:27:44 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39182>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39182





------- Additional Comments From ebourg@apache.org  2006-04-11 18:27 -------
Thanks for the patch ! 

There are several aspects to consider in order to preserve completly the file
structure:
- the comments (property or section comments)
- the blank lines
- the order of the properties
- the proper insertion of the new properties next to the similar properties
- the format of the properties:
    * multiline or single line lists
    * decimal or hexadecimal numbers
    * text wrapped on multiple lines
    * etc

To handle this I'd like to introduce a Layout class attached to the
configuration rather than overloading the class with more methods. This class
will maintain a List of the elements of the file. This list would look like this:

    <comment: Configuration file for the Foo application>
    <blank line>
    <comment: Main properties>
    property: foo.key.a
    property: foo.key.b
    property: foo.key.bar.a
    <blank line>
    <comment: Secondary properties>
    property: bar.key.a
    property: bar.key.b
    property: bar.key.c

Every time a property is added or removed from the configuration, the layout
will be notified and it will update the list accordingly. It will attempt to
group the properties by prefix. For example, if the foo.key.bar.b property is
added, it will look for the last property sharing the same prefix, that's
foo.key.bar.a, and insert it after:

    ...
    property: foo.key.a
    property: foo.key.b
    property: foo.key.bar.a
    property: foo.key.bar.b
    ...

If no similar property is found the property is added at the end of the list.

For every property a format is attached, that's what specifies the property
specific details like the list format or the number format.

It'll be possible to disable this feature if performance is more important than
the correctness of the file. Either by adding a flag to the layout, or by using
a NullLayout that would produce the same result we have today.



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message