commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Lark (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CONFIGURATION-636) Allow a user-defined order in the PropertiesConfigurationLayout.save method.
Date Tue, 05 Jul 2016 22:04:11 GMT

     [ https://issues.apache.org/jira/browse/CONFIGURATION-636?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Tim Lark updated CONFIGURATION-636:
-----------------------------------
    Description: 
For .properties file manipulation, I have a use case that requires something like "addKeyAfterKey(String
keyToAdd, String afterKey)".  This allows a property to be written after some other property
when saving.

I have extended PropertiesConfigurationLayout to accomplish this new behavior.  Unfortunately,
the save method iterates over a private member (layoutData), so I have no control over the
final file order.

An easy fix for my use case would be to change line 564 of PropertiesConfigurationLayout.java
to use the public getKeys() method instead of layoutData.keySet():
{noformat}
FROM: for (String key : layoutData.keySet())
TO:   for (String key : getKeys())
{noformat}

Then I could override getKeys() to return the required order for saving.

  was:
For .properties file manipulation, I have a use case that requires something like "addKeyAfterKey(String
keyToAdd, String afterKey)".  This allows a property to be written after some other property
when saving.

I have extended PropertiesConfigurationLayout to accomplish this new behavior.  Unfortunately,
the save method iterates over a private member (layoutData), so I have no control over the
final file order.

An easy fix for my use case would be to change line 564 to use the public getKeys() method
instead of layoutData.keySet():
{noformat}
FROM: for (String key : layoutData.keySet())
TO:   for (String key : getKeys())
{noformat}

Then I could override getKeys() to return the required order for saving.


> Allow a user-defined order in the PropertiesConfigurationLayout.save method.
> ----------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-636
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-636
>             Project: Commons Configuration
>          Issue Type: Improvement
>          Components: Format
>    Affects Versions: 2.0
>            Reporter: Tim Lark
>
> For .properties file manipulation, I have a use case that requires something like "addKeyAfterKey(String
keyToAdd, String afterKey)".  This allows a property to be written after some other property
when saving.
> I have extended PropertiesConfigurationLayout to accomplish this new behavior.  Unfortunately,
the save method iterates over a private member (layoutData), so I have no control over the
final file order.
> An easy fix for my use case would be to change line 564 of PropertiesConfigurationLayout.java
to use the public getKeys() method instead of layoutData.keySet():
> {noformat}
> FROM: for (String key : layoutData.keySet())
> TO:   for (String key : getKeys())
> {noformat}
> Then I could override getKeys() to return the required order for saving.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message