avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcus Crafter <craft...@osa.de>
Subject Parameters.toProperties() ?
Date Sun, 11 Aug 2002 14:36:01 GMT
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:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message