From 573314875be0d69cc5d674ed3039e44460b0b098 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 13 Apr 2007 20:47:04 +0000 Subject: [PATCH] Widened. --- .../threerings/getdown/util/ConfigUtil.java | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/java/com/threerings/getdown/util/ConfigUtil.java b/src/java/com/threerings/getdown/util/ConfigUtil.java index 1154fce..cef98ed 100644 --- a/src/java/com/threerings/getdown/util/ConfigUtil.java +++ b/src/java/com/threerings/getdown/util/ConfigUtil.java @@ -37,18 +37,17 @@ import com.samskivert.util.StringUtil; import com.threerings.getdown.Log; /** - * Parses a file containing key/value pairs and returns a {@link HashMap} - * with the values. Keys may be repeated, in which case they will be made - * to reference an array of values. + * Parses a file containing key/value pairs and returns a {@link HashMap} with the values. Keys may + * be repeated, in which case they will be made to reference an array of values. */ public class ConfigUtil { /** - * Parses a configuration file containing key/value pairs. The file - * must be in the UTF-8 encoding. + * Parses a configuration file containing key/value pairs. The file must be in the UTF-8 + * encoding. * - * @return a list of String[] instances containing the - * key/value pairs in the order they were parsed from the file. + * @return a list of String[] instances containing the key/value pairs in the + * order they were parsed from the file. */ public static List parsePairs (File config, boolean checkPlatform) throws IOException @@ -61,8 +60,7 @@ public class ConfigUtil FileInputStream fin = null; try { fin = new FileInputStream(config); - BufferedReader bin = - new BufferedReader(new InputStreamReader(fin, "UTF-8")); + BufferedReader bin = new BufferedReader(new InputStreamReader(fin, "UTF-8")); String line = null; while ((line = bin.readLine()) != null) { // nix comments @@ -103,14 +101,12 @@ public class ConfigUtil platform = platform.substring(1); if (osname.indexOf(platform) != -1) { Log.info("Skipping [platform=!" + platform + - ", key=" + pair[0] + - ", value=" + pair[1] + "]."); + ", key=" + pair[0] + ", value=" + pair[1] + "]."); continue; } } else if (osname.indexOf(platform) == -1) { Log.info("Skipping [platform=" + platform + - ", key=" + pair[0] + - ", value=" + pair[1] + "]."); + ", key=" + pair[0] + ", value=" + pair[1] + "]."); continue; } } @@ -128,23 +124,21 @@ public class ConfigUtil } /** - * Parses a configuration file containing key/value pairs. The file - * must be in the UTF-8 encoding. + * Parses a configuration file containing key/value pairs. The file must be in the UTF-8 + * encoding. * - * @return a map from keys to values, where a value will be an array - * of strings if more than one key/value pair in the config file was - * associated with the same key. + * @return a map from keys to values, where a value will be an array of strings if more than + * one key/value pair in the config file was associated with the same key. */ - public static HashMap parseConfig (File config, - boolean checkPlatform) + public static HashMap parseConfig (File config, boolean checkPlatform) throws IOException { List pairs = parsePairs(config, checkPlatform); HashMap data = new HashMap(); - // I thought that we could use HashMap and put - // new String[] {pair[1]} for the null case, but it mysteriously dies - // on launch, so leaving it as HashMap for now + // I thought that we could use HashMap and put new String[] {pair[1]} for + // the null case, but it mysteriously dies on launch, so leaving it as HashMap for now for (Iterator iter = pairs.iterator(); iter.hasNext(); ) { String[] pair = (String[])iter.next(); Object value = data.get(pair[0]); @@ -165,9 +159,8 @@ public class ConfigUtil } /** - * Massages a single string into an array and leaves existing array - * values as is. Simplifies access to parameters that are expected to - * be arrays. + * Massages a single string into an array and leaves existing array values as is. Simplifies + * access to parameters that are expected to be arrays. */ public static String[] getMultiValue (HashMap data, String name) {