You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Marcus Crafter <cr...@osa.de> on 2002/08/11 16:36:01 UTC
Parameters.toProperties() ?
Hi All,
Hope everyone is having a nice weekend! :)
I'm working with a 3rd party library that uses
java.util.Properties objects to store configuration data.
I currently have a Framework Parameters object with the config data in
it, and are atm manually converting it to a Properties object.
I was thinking that this operation of converting a Parameters
object to a Properties object was general enough to go into the
Parameters class itself ?
Something like:
/**
* Helper method to convert an Avalon Parameters object into a Java Util
* Properties object.
*
* @param p a <code>Parameters</code> instance
* @return a <code>Properties</code> instance
*/
private Properties parametersToProperties(Parameters p)
{
Properties prop = new Properties();
String[] names = p.getNames();
for (int i = 0; i < names.length; ++i)
{
// "" is the default value, since getNames() proves it will exist
prop.setProperty(names[i], p.getParameter(names[i], ""));
}
return prop;
}
Any thoughts ?
Cheers,
Marcus
--
.....
,,$$$$$$$$$, Marcus Crafter
;$' '$$$$: Computer Systems Engineer
$: $$$$: ManageSoft GmbH
$ o_)$$$: 82-84 Mainzer Landstrasse
;$, _/\ &&:' 60327 Frankfurt Germany
' /( &&&
\_&&&&' email: crafterm@managesoft.com
&&&&.
&&&&&&&:
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Parameters.toProperties() ?
Posted by Marcus Crafter <cr...@fztig938.bank.dresdner.net>.
ok, just committed the change.
Cheers,
Marcus
On Mon, Aug 12, 2002 at 07:58:06AM +1000, Peter Donald wrote:
> +1
>
> On Mon, 12 Aug 2002 00:36, Marcus Crafter wrote:
> > Hi All,
> >
> > Hope everyone is having a nice weekend! :)
> >
> > I'm working with a 3rd party library that uses
> > java.util.Properties objects to store configuration data.
> >
> > I currently have a Framework Parameters object with the config data in
> > it, and are atm manually converting it to a Properties object.
> >
> > I was thinking that this operation of converting a Parameters
> > object to a Properties object was general enough to go into the
> > Parameters class itself ?
> >
> > Something like:
> >
> > /**
> > * Helper method to convert an Avalon Parameters object into a Java Util
> > * Properties object.
> > *
> > * @param p a <code>Parameters</code> instance
> > * @return a <code>Properties</code> instance
> > */
> > private Properties parametersToProperties(Parameters p)
> > {
> > Properties prop = new Properties();
> > String[] names = p.getNames();
> >
> > for (int i = 0; i < names.length; ++i)
> > {
> > // "" is the default value, since getNames() proves it will exist
> > prop.setProperty(names[i], p.getParameter(names[i], ""));
> > }
> >
> > return prop;
> > }
> >
> > Any thoughts ?
> >
> > Cheers,
> >
> > Marcus
>
> --
> Cheers,
>
> Peter Donald
> *------------------------------------------------*
> | You can't wake a person who is pretending |
> | to be asleep. -Navajo Proverb. |
> *------------------------------------------------*
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
.....
,,$$$$$$$$$, Marcus Crafter
;$' '$$$$: Computer Systems Engineer
$: $$$$: ManageSoft GmbH
$ o_)$$$: 82-84 Mainzer Landstrasse
;$, _/\ &&:' 60327 Frankfurt Germany
' /( &&&
\_&&&&'
&&&&.
&&&&&&&:
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Parameters.toProperties() ?
Posted by Peter Donald <pe...@apache.org>.
+1
On Mon, 12 Aug 2002 00:36, Marcus Crafter wrote:
> Hi All,
>
> Hope everyone is having a nice weekend! :)
>
> I'm working with a 3rd party library that uses
> java.util.Properties objects to store configuration data.
>
> I currently have a Framework Parameters object with the config data in
> it, and are atm manually converting it to a Properties object.
>
> I was thinking that this operation of converting a Parameters
> object to a Properties object was general enough to go into the
> Parameters class itself ?
>
> Something like:
>
> /**
> * Helper method to convert an Avalon Parameters object into a Java Util
> * Properties object.
> *
> * @param p a <code>Parameters</code> instance
> * @return a <code>Properties</code> instance
> */
> private Properties parametersToProperties(Parameters p)
> {
> Properties prop = new Properties();
> String[] names = p.getNames();
>
> for (int i = 0; i < names.length; ++i)
> {
> // "" is the default value, since getNames() proves it will exist
> prop.setProperty(names[i], p.getParameter(names[i], ""));
> }
>
> return prop;
> }
>
> Any thoughts ?
>
> Cheers,
>
> Marcus
--
Cheers,
Peter Donald
*------------------------------------------------*
| You can't wake a person who is pretending |
| to be asleep. -Navajo Proverb. |
*------------------------------------------------*
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>