Added a mechanism for retrieving a set of sub-properties (whose keys all
start with a particular prefix) from a configuration object. git-svn-id: https://samskivert.googlecode.com/svn/trunk@688 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: test.properties,v 1.1 2001/07/12 02:44:34 mdb Exp $
|
||||
# $Id: test.properties,v 1.2 2002/03/28 22:21:06 mdb Exp $
|
||||
#
|
||||
# A test properties file
|
||||
|
||||
@@ -8,3 +8,6 @@ prop2 = twenty five
|
||||
prop3 = 9, 8, 7, 6
|
||||
prop4 = one, two, three,, and a half, four
|
||||
# prop5 = not defined
|
||||
|
||||
sub.sub1 = 5
|
||||
sub.sub2 = whee!
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
//
|
||||
// $Id: ConfigTest.java,v 1.2 2002/03/28 21:50:27 mdb Exp $
|
||||
// $Id: ConfigTest.java,v 1.3 2002/03/28 22:21:06 mdb Exp $
|
||||
|
||||
package com.samskivert.util;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
@@ -43,6 +44,12 @@ public class ConfigTest extends TestCase
|
||||
|
||||
Iterator iter = config.keys();
|
||||
System.out.println("Keys: " + StringUtil.toString(iter));
|
||||
|
||||
config.setValue("sub.sub3", "three");
|
||||
|
||||
Properties subprops = config.getSubProperties("sub");
|
||||
System.out.println("Sub: " +
|
||||
StringUtil.toString(subprops.propertyNames()));
|
||||
}
|
||||
|
||||
public static Test suite ()
|
||||
|
||||
Reference in New Issue
Block a user