diff --git a/src/main/java/com/threerings/getdown/data/Application.java b/src/main/java/com/threerings/getdown/data/Application.java index f9c8b5e..98b456e 100644 --- a/src/main/java/com/threerings/getdown/data/Application.java +++ b/src/main/java/com/threerings/getdown/data/Application.java @@ -57,8 +57,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Map.Entry; +import java.util.Map; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -421,7 +421,7 @@ public class Application throws IOException { // parse our configuration file - HashMap cdata = null; + Map cdata = null; try { cdata = ConfigUtil.parseConfig(_config, checkPlatform); } catch (FileNotFoundException fnfe) { @@ -602,7 +602,7 @@ public class Application ui.progressBar = parseColor(cdata, "ui.progress_bar", ui.progressBar); ui.status = parseRect(cdata, "ui.status", ui.status); ui.statusText = parseColor(cdata, "ui.status_text", ui.statusText); - ui.textShadow = parseColor(cdata, "ui.text_shadow", ui.textShadow, false); + ui.textShadow = parseColor(cdata, "ui.text_shadow", ui.textShadow); ui.backgroundImage = (String)cdata.get("ui.background_image"); if (ui.backgroundImage == null) { // support legacy format ui.backgroundImage = (String)cdata.get("ui.background"); @@ -1343,8 +1343,8 @@ public class Application } /** Used to parse resources with the specified name. */ - protected void parseResources (HashMap cdata, String name, boolean unpack, - ArrayList list) + protected void parseResources (Map cdata, String name, boolean unpack, + List list) { String[] rsrcs = ConfigUtil.getMultiValue(cdata, name); if (rsrcs == null) { @@ -1360,51 +1360,35 @@ public class Application } /** Used to parse rectangle specifications from the config file. */ - protected Rectangle parseRect (HashMap cdata, String name, Rectangle def) + protected Rectangle parseRect (Map cdata, String name, Rectangle def) { String value = (String)cdata.get(name); - Rectangle rect = parseRect(value); - if (rect == null) { - log.warning("Ignoring invalid '" + name + "' config '" + value + "'."); - } else { - return rect; - } - return def; + Rectangle rect = parseRect(name, value); + return (rect == null) ? def : rect; } /** * Takes a comma-separated String of four integers and returns a rectangle using those ints as * the its x, y, width, and height. */ - public static Rectangle parseRect (String value) + public static Rectangle parseRect (String name, String value) { if (!StringUtil.isBlank(value)) { int[] v = StringUtil.parseIntArray(value); if (v != null && v.length == 4) { return new Rectangle(v[0], v[1], v[2], v[3]); } + log.warning("Ignoring invalid '" + name + "' config '" + value + "'."); } return null; } /** Used to parse color specifications from the config file. */ - protected Color parseColor (HashMap cdata, String name, Color def) - { - return parseColor(cdata, name, def, true); - } - - /** Used to parse color specifications from the config file. */ - protected Color parseColor (HashMap cdata, String name, Color def, - boolean required) + protected Color parseColor (Map cdata, String name, Color def) { String value = (String)cdata.get(name); Color color = parseColor(value); - if (color == null && required) { - log.warning("Ignoring invalid '" + name + "' config '" + value + "'."); - } else { - return color; - } - return def; + return (color == null) ? def : color; } /** @@ -1424,7 +1408,7 @@ public class Application } /** Parses a list of strings from the config file. */ - protected String[] parseList (HashMap cdata, String name) + protected String[] parseList (Map cdata, String name) { String value = (String)cdata.get(name); return (value == null) ? new String[0] : StringUtil.parseStringArray(value); @@ -1482,16 +1466,15 @@ public class Application protected int _javaVersion; protected String _javaLocation; - protected ArrayList _codes = new ArrayList(); - protected ArrayList _resources = new ArrayList(); + protected List _codes = new ArrayList(); + protected List _resources = new ArrayList(); - protected ArrayList _auxgroups = new ArrayList(); - protected HashMap> _auxrsrcs = - new HashMap>(); - protected HashMap _auxactive = new HashMap(); + protected List _auxgroups = new ArrayList(); + protected Map> _auxrsrcs = new HashMap>(); + protected Map _auxactive = new HashMap(); - protected ArrayList _jvmargs = new ArrayList(); - protected ArrayList _appargs = new ArrayList(); + protected List _jvmargs = new ArrayList(); + protected List _appargs = new ArrayList(); protected String[] _baseJvmArgs = new String[0]; protected String[] _baseAppArgs = new String[0]; diff --git a/src/main/java/com/threerings/getdown/launcher/Getdown.java b/src/main/java/com/threerings/getdown/launcher/Getdown.java index e100cf0..f4f8173 100644 --- a/src/main/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/main/java/com/threerings/getdown/launcher/Getdown.java @@ -51,7 +51,7 @@ import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Map; import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; @@ -282,7 +282,7 @@ public abstract class Getdown extends Thread File pfile = _app.getLocalPath("proxy.txt"); if (pfile.exists()) { try { - HashMap pconf = ConfigUtil.parseConfig(pfile, false); + Map pconf = ConfigUtil.parseConfig(pfile, false); setProxyProperties((String)pconf.get("host"), (String)pconf.get("port")); return true; } catch (IOException ioe) { @@ -546,7 +546,7 @@ public abstract class Getdown extends Thread reportTrackingEvent("jvm_start", -1); updateStatus("m.downloading_java"); - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add(vmjar); download(list); @@ -598,7 +598,7 @@ public abstract class Getdown extends Thread // attempt to download the patch files Resource patch = _app.getPatchResource(null); if (patch != null) { - ArrayList list = new ArrayList(); + List list = new ArrayList(); list.add(patch); // add the auxiliary group patch files for activated groups diff --git a/src/main/java/com/threerings/getdown/launcher/GetdownAppletConfig.java b/src/main/java/com/threerings/getdown/launcher/GetdownAppletConfig.java index 74d48df..c420e82 100644 --- a/src/main/java/com/threerings/getdown/launcher/GetdownAppletConfig.java +++ b/src/main/java/com/threerings/getdown/launcher/GetdownAppletConfig.java @@ -180,7 +180,7 @@ public class GetdownAppletConfig // This allows us to configure the status panel from applet parameters in case something // goes horribly wrong before we get a chance to read getdown.txt (like when the user // rejects write permission for the applet) - statusBounds = Application.parseRect(getParameter("ui.status")); + statusBounds = Application.parseRect("ui.status", getParameter("ui.status")); statusColor = Application.parseColor(getParameter("ui.status_text")); } diff --git a/src/main/java/com/threerings/getdown/util/ConfigUtil.java b/src/main/java/com/threerings/getdown/util/ConfigUtil.java index 55e9409..d605c47 100644 --- a/src/main/java/com/threerings/getdown/util/ConfigUtil.java +++ b/src/main/java/com/threerings/getdown/util/ConfigUtil.java @@ -34,6 +34,7 @@ import java.io.Reader; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; import com.samskivert.util.StringUtil; @@ -82,10 +83,10 @@ public class ConfigUtil * @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 Map parseConfig (File config, boolean checkPlatform) throws IOException { - HashMap data = new HashMap(); + Map 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 data, String name) + public static String[] getMultiValue (Map data, String name) { Object value = data.get(name); if (value instanceof String) {