commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <>
Subject [jira] Commented: (CONFIGURATION-370) Customizing the Properties Reader
Date Sat, 14 Mar 2009 21:04:50 GMT


Oliver Heger commented on CONFIGURATION-370:

I think the API provided by the nested {{PropertiesReader}} class of {{PropertiesConfiguration}}
is powerful enough for customizing the reading of non-standard properties files. Maybe the
*private static* {{parseProperty()}} method should be made *protected*. Then specialized reader
classes can be derived from {{PropertiesReader}} that implement the desired treatment of property

What is missing is a convenient way to inject a custom {{PropertiesReader}} implementation
into the load operation of {{PropertiesConfiguration}}. We could add an interface for this
purpose which could look like the following:

public interface IOFactory
    PropertiesReader createPropertiesReader(Reader in);

    PropertiesWriter createPropertiesWriter(Writer out, char delimiter);

This interface would also allow customizing the writer. {{PropertiesConfiguration}} would
provide new get and set methods for accessing the {{IOFactory}}.

> Customizing the Properties Reader
> ---------------------------------
>                 Key: CONFIGURATION-370
>                 URL:
>             Project: Commons Configuration
>          Issue Type: New Feature
>    Affects Versions: 1.6
>         Environment: Properties File Reader.
>            Reporter: Andrew Hughes
> Currently Commons Configuration does not offer support to handle non-standard property
file parsing. Inparticular, you can't parse properties where the key has whitespace.
> Taken from thread on mailing list:
> {quote}
> Howdy,
> We've got legacy/shared property files for our config (i.e. can't change the property
files to solve this). We're trying to use commons-config but it has difficulty dealing with
our properties files as the key's contain whitespace.
> Any help on how I can resolve this would be most welcomed :)
> Example Property:
> Welcome Message=Hello World
> Cheers.
> {quote}
> Response:
> {quote}
> The current code does not seem to support whitespace in property keys.
> PropertiesConfiguration uses PropertiesConfigurationLayout.load() for loading and parsing
configuration files, which in turn delegates to the inner class PropertiesConfiguration.PropertiesReader.
This class interprets all whitespace as end markers of the property key.
> It is probably not trivial to inject your own reader for properties files. Maybe you
can create a custom layout class derived from PropertiesConfigurationLayout that overrides
the load() method. You would have to override PropertiesConfiguration.createLayout() to activate
your new layout class.
> Given these problems it would probably be a good idea if the library offered better support
for customizing the properties reader. If you consider this helpful, feel free to open an
enhancement ticket in Jira [1].
> Oliver
> {quote}

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message