On Wed, Sep 14, 2011 at 12:37 PM, sebb <[email protected]> wrote: > On 14 September 2011 09:23, Wieland Gmeiner <[email protected]> wrote: >> On Wed, Sep 14, 2011 at 1:15 AM, sebb <[email protected]> wrote: >>> On 13 September 2011 23:19, Wieland Gmeiner <[email protected]> >>> wrote: >>>> On Wed, Sep 14, 2011 at 12:06 AM, sebb <[email protected]> wrote: >>>>> On 13 September 2011 21:31, Oliver Heger <[email protected]> >>>>> wrote: >>>>>>> Is there a possiblity to tweak the PropertiesConfiguration so that it >>>>>>> preserves the original layout over a load/store cycle? >>>>> >>>>> Why do you want to do this? >>>> >>>> Because I'm programmatically changing configuration files (e.g. >>>> inserting additional properties) and it would be nice not to mess up >>>> the layout of the original files. A sysadmin won't be pleased if some >>>> update program changes the layout of his handcrafted config files. I >>>> wouldn't. >>> >>> In that case, I think you are going to have to write your own output method. >>> >>> So long as you don't change any of the input settings, you should just >>> be able to append the new ones to the end. >> >> I also have to change values of already existing properties, so >> appending only is not a choice. > > Fixing property values in place is going to be a lot harder in general. > > As already noted, the original formatting is dropped when the file is loaded. > But even if the format were retained, it's still tricky to rewrite the > file with the new values if spacing is significant. > What if the new values are longer or shorter? Should spacing be adjusted? > If the original property has a single value, and another value is > added, should this be on the same line or the next? > And what spacing should be used? > > Try writing down the rules for updating the file assuming that the > person doing it has no knowledge of what the format is trying to > achieve.
I know it's hard, because I tried to do that for xml and properties with the Java SE alone. While handling the "real" work (i.e. merging nodes/properties) is not so hard, the layout problem was driving me nuts, thats why I started to search some library where someone already solved that problem for me. But it seems that will remain on the todo list at the moment. >> Btw, for appending only I don't need configurations at all. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
