commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre8rou <pierre8r-nab...@yahoo.fr>
Subject [Commons Configuration] How SubsetConfiguration works ?
Date Fri, 05 Sep 2008 18:27:55 GMT

Hello,


With this code :
---------------

package com.test.configuration;

import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.SubsetConfiguration;

public class testCommonsConfig001 {

	public static void main(String[] args) {

		BaseConfiguration config = new BaseConfiguration();

		config.addProperty("prefix1.car01", 11.1);
		config.addProperty("prefix1.car02", 22.2);
		config.addProperty("prefix1.car03", 33.3);

		config.addProperty("prefix2.car01", 11.1);
		config.addProperty("prefix2.car02", 22.2);
		config.addProperty("prefix2.car03", 33.3);

		System.out.println(config.getDouble("prefix1.car01"));
		System.out.println(config.getDouble("prefix1.car02"));
		System.out.println(config.getDouble("prefix1.car03"));

		SubsetConfiguration subsetPre01 = new SubsetConfiguration(config,
				"prefix1");

		System.out.println(subsetPre01.getDouble("car01"));

	}
}


I got this console message :
---------------------------

Exception in thread "main" java.util.NoSuchElementException: 'car01' doesn't
map to an existing object
	at
org.apache.commons.configuration.AbstractConfiguration.getDouble(AbstractConfiguration.java:734)
	at
com.test.configuration.testCommonsConfig001.main(testCommonsConfig001.java:30)


Why car01 does not exist ?

Thanks,

Pierre8r

-- 
View this message in context: http://www.nabble.com/-Commons-Configuration--How-SubsetConfiguration-works---tp19337003p19337003.html
Sent from the Commons - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message