Minor fiddling.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@950 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2002-11-26 01:57:22 +00:00
parent 186221f011
commit a2d6c849b9
2 changed files with 16 additions and 12 deletions
@@ -1,5 +1,5 @@
// //
// $Id: Config.java,v 1.17 2002/11/24 04:51:02 mdb Exp $ // $Id: Config.java,v 1.18 2002/11/26 01:57:22 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -104,17 +104,14 @@ public class Config
public Config (String path) public Config (String path)
{ {
// first load up our default prefs // first load up our default prefs
_props = new Properties();
try { try {
// append the file suffix onto the path // append the file suffix onto the path
String ppath = path + PROPS_SUFFIX; String ppath = path + PROPS_SUFFIX;
// load the properties file // load the properties file
_props = ConfigUtil.loadInheritedProperties(ppath); ConfigUtil.loadInheritedProperties(ppath, _props);
if (_props == null) {
Log.warning("Unable to locate configuration definitions " +
"[path=" + path + "].");
_props = new Properties();
}
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Unable to load configuration [path=" + path + Log.warning("Unable to load configuration [path=" + path +
@@ -1,5 +1,5 @@
// //
// $Id: ConfigUtil.java,v 1.8 2002/11/25 22:25:20 mdb Exp $ // $Id: ConfigUtil.java,v 1.9 2002/11/26 01:57:22 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -58,8 +58,6 @@ public class ConfigUtil
* Like {@link #loadProperties(String)} but this method uses the * Like {@link #loadProperties(String)} but this method uses the
* supplied class loader rather than the class loader used to load the * supplied class loader rather than the class loader used to load the
* <code>ConfigUtil</code> class. * <code>ConfigUtil</code> class.
*
* @see #loadProperties(String)
*/ */
public static Properties loadProperties (String path, ClassLoader loader) public static Properties loadProperties (String path, ClassLoader loader)
throws IOException throws IOException
@@ -223,12 +221,21 @@ public class ConfigUtil
path, ConfigUtil.class.getClassLoader()); path, ConfigUtil.class.getClassLoader());
} }
/**
* Like {@link #loadInheritedProperties(String)} but loads the
* properties into the supplied target object.
*/
public static void loadInheritedProperties (String path, Properties target)
throws IOException
{
loadInheritedProperties(
path, ConfigUtil.class.getClassLoader(), target);
}
/** /**
* Like {@link #loadInheritedProperties(String)} but this method uses * Like {@link #loadInheritedProperties(String)} but this method uses
* the supplied class loader rather than the class loader used to load * the supplied class loader rather than the class loader used to load
* the <code>ConfigUtil</code> class. * the <code>ConfigUtil</code> class.
*
* @see #loadInheritedProperties(String)
*/ */
public static Properties loadInheritedProperties ( public static Properties loadInheritedProperties (
String path, ClassLoader loader) String path, ClassLoader loader)