commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Diggory" <mdigg...@gmail.com>
Subject Re: [configuration] Variable Interpolation doesn't happen in subset() and configurationAt()
Date Mon, 04 Dec 2006 02:25:35 GMT
On 12/3/06, Oliver Heger <oliver.heger@oliver-heger.de> wrote:
>
> I have committed a fix, so subset() should work now, too.


Thanks, I'll start using the next nightly build

The difference between subset() and configurationAt() is that subset()
> allows you to select arbitrary subsets of a configuration's properties
> while the expression passed to configurationAt() must select exactly one
> configuration node.
>
> As an example consider the following configuration for database tables:
>
> <config>
>    <tables>
>      <table>
>        <name>tab1</name>
>        <fields>
>          <field>
>            <name>field1</name>
>            <type>NUMBER</name>
>          </field>
>          <field>
>            ...
>          </field>
>          ...
>        </fields>
>      </table>
>      <table>
>        <name>tab2</name>
>        ...
>      </table>
>      ...
>    </tables>
> </config>
>
> subset() allows you to select properties that need not belong to the
> same parent node, e.g.
> Configuration sub = config.subset("tables.table.fields.field");
>
> This will return a configuration that allows you easy access to all
> defined table fields. Using configurationAt() in contrast requires that
> the passed in key selects exactly one node of the hierarchical
> structure, e.g.
> Configuration sub =
> config.configurationAt("tables.table(0).fields.field(0)");
>
> If you can live with this limitation, using configurationAt() is
> recommended. The returned configuration is far more lightweight.


 How does this map into Properties files (it seems to me Properties files
are kind of like all children do not share the same parent)?

We'll move eventually to XML format files, but it will take some time to
transition.

-Mark

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message