You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by James Watkin <ja...@anderson.ucla.edu> on 2007/10/10 00:03:40 UTC
Jakarta Commons Configuration - Problem with Variable Interpolation
and StringArray
I'm able to use Jakarta Commons Configuration with .properties files and
String[] properties, but when I use variable interpolation to refer to a
String[] property, it only returns the first element. Example:
.properties file contents:
test.email.addresses = firstName1.LastName1@mydomain.edu,
firstName2.LastName2@mydomain.edu
test.email.recipients = ${test.email.addresses}
Code:
String[] testEmailAddresses = config.getStringArray("test.email.addresses");
String[] testEmailRecipients =
config.getStringArray("test.email.recipients");
System.out.println("testEmailAddresses = " +
ArrayUtils.toString(testEmailAddresses));
System.out.println("testEmailRecipients = " +
ArrayUtils.toString(testEmailRecipients));
Output:
testEmailAddresses =
{firstName1.LastName1@mydomain.edu,firstName2.LastName2@mydomain.edu}
testEmailRecipients = {firstName1.LastName1@mydomain.edu}
Shouldn't testEmailRecipients get the same String[] value as
testEmailAddresses? Am I doing something wrong, or can't this be done?
Is there a special recursive variable interpolation character for arrays?
- Jim
______________________________
James Watkin
ACIS Software Development
UCLA Anderson School
james.watkin@anderson.ucla.edu
Voice: 1-310-825-5030
Fax: 1-310-825-4835
______________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: Jakarta Commons Configuration - Problem with Variable Interpolation
and StringArray
Posted by Oliver Heger <ol...@oliver-heger.de>.
James Watkin wrote:
> I'm able to use Jakarta Commons Configuration with .properties files and
> String[] properties, but when I use variable interpolation to refer to a
> String[] property, it only returns the first element. Example:
>
> .properties file contents:
> test.email.addresses = firstName1.LastName1@mydomain.edu,
> firstName2.LastName2@mydomain.edu
>
> test.email.recipients = ${test.email.addresses}
>
>
> Code:
> String[] testEmailAddresses =
> config.getStringArray("test.email.addresses");
>
> String[] testEmailRecipients =
> config.getStringArray("test.email.recipients");
>
> System.out.println("testEmailAddresses = " +
> ArrayUtils.toString(testEmailAddresses));
>
> System.out.println("testEmailRecipients = " +
> ArrayUtils.toString(testEmailRecipients));
>
>
> Output:
> testEmailAddresses =
> {firstName1.LastName1@mydomain.edu,firstName2.LastName2@mydomain.edu}
> testEmailRecipients = {firstName1.LastName1@mydomain.edu}
>
> Shouldn't testEmailRecipients get the same String[] value as
> testEmailAddresses? Am I doing something wrong, or can't this be done?
> Is there a special recursive variable interpolation character for arrays?
>
> - Jim
I am sorry, but interpolation of array values is not supported. Our
interpolation implementation is pretty much String-based (behind the
scenes we use the text package of Commons Lang [1], which only operates
on Strings). So extending this to other types or even arrays and
collections won't be trivial.
Oliver
[1] http://commons.apache.org/lang/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org