commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CONFIGURATION-401) HierarchicalConfiguration does not support hierarchy from property files
Date Mon, 09 Nov 2009 20:52:32 GMT

    [ https://issues.apache.org/jira/browse/CONFIGURATION-401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12775130#action_12775130
] 

Oliver Heger commented on CONFIGURATION-401:
--------------------------------------------

After scanning through the sources I think there is indeed a class that does what you want
(or at least partly): {{HierarchicalConfigurationConverter}}. This class iterates over the
keys of an arbitrary {{Configuration}} object and generates a series of start element and
end element events that can be used to construct a corresponding hierarchical configuration.
The tree structure generated this way should be close to the one you need.

There are however some problems:
* The class is somewhat experimental. It is not advertised in the documentation, and I am
not sure whether it was used by anybody.
* It is an abstract class. There is one concrete subclass used internally by {{BaseConfigurationXMLReader}}.
{{BaseConfigurationXMLReader}} allows a configuration object to be processed by an XML parser.

So I think you have the following options:
* You can create a concrete subclass of {{HierarchicalConfigurationConverter}} that creates
{{ConfigurationNode}} objects corresponding to the start and end element notifications.
* You can try {{BaseConfigurationXMLReader}} and generate XML documents from a {{PropertiesConfiguration}}.
These documents can then be parsed by a {{XMLConfiguration}}. If you follow this road, you
might want to have a look at the unit tests for {{BaseConfigurationXMLReader}}.

Hope this helps.

> HierarchicalConfiguration does not support hierarchy  from property files
> -------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-401
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-401
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Expression engine
>    Affects Versions: 1.6
>         Environment: windows/Linux
>            Reporter: yair ogen
>
> If you have hierarchy like this:
> persons.person.name=1
> persons.person.surName=2
> persons.person.phoneNum=3
> persons.person.name=4
> persons.person.surName=5
> persons.person.phoneNum=6
> persons.person.name=7
> persons.person.surName=8
> persons.person.phoneNum=9
> If I have a regular property configuration that loaded a file containing in the above.
then I transform into HierarchicalConfiguration  using: ConfigurationUtils.convertToHierarchical(configuration).
> The tree is not right.
> I can do this:
> hierarchicalConfiguration.subset("persons").subset("person(0)").getKeys()
> but this returned empty iterator:
> hierarchicalConfiguration.subset("persons").subset("person(1)").getKeys()
> Only the first person is available.

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


Mime
View raw message