Code hygiene. Not as pedantic as I'd like, but I couldn't resist the huge time
saver that is Eclipse's "Infer generic types" which leaves HashMap and ArrayList as the declared type where I would normally prefer to change those to Map and List and use Maps and Lists to instantiate them. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@593 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -141,14 +141,15 @@ public class ComponentBundlerTask extends Task
|
||||
"definitions via the 'actiondef' attribute.");
|
||||
|
||||
// parse in the action tilesets
|
||||
HashMap actsets = parseActionTileSets();
|
||||
HashMap<String, TileSet> actsets = parseActionTileSets();
|
||||
|
||||
// load up our component ID broker
|
||||
ComponentIDBroker broker = loadBroker(_mapfile);
|
||||
|
||||
// check to see if any of the source files are newer than the
|
||||
// target file
|
||||
ArrayList sources = (ArrayList)_filesets.clone();
|
||||
ArrayList<Object> sources = new ArrayList<Object>();
|
||||
sources.addAll(_filesets);
|
||||
sources.add(_mapfile);
|
||||
sources.add(_actionDef);
|
||||
long newest = getNewestDate(sources);
|
||||
@@ -187,7 +188,7 @@ public class ComponentBundlerTask extends Task
|
||||
String[] info = decomposePath(cfile.getPath());
|
||||
|
||||
// make sure we have an action tileset definition
|
||||
TileSet aset = (TileSet)actsets.get(info[2]);
|
||||
TileSet aset = actsets.get(info[2]);
|
||||
if (aset == null) {
|
||||
System.err.println(
|
||||
"No tileset definition for component action " +
|
||||
@@ -292,7 +293,7 @@ public class ComponentBundlerTask extends Task
|
||||
}
|
||||
}
|
||||
|
||||
protected long getNewestDate (ArrayList sources)
|
||||
protected long getNewestDate (ArrayList<Object> sources)
|
||||
{
|
||||
long newest = 0L;
|
||||
for (int ii = 0; ii < sources.size(); ii++) {
|
||||
@@ -414,7 +415,7 @@ public class ComponentBundlerTask extends Task
|
||||
* Parses the action tileset definitions and puts them into a hash
|
||||
* map, keyed on action name.
|
||||
*/
|
||||
protected HashMap parseActionTileSets ()
|
||||
protected HashMap<String, TileSet> parseActionTileSets ()
|
||||
{
|
||||
Digester digester = new Digester();
|
||||
digester.addSetProperties("actions" + ActionRuleSet.ACTION_PATH);
|
||||
@@ -422,7 +423,7 @@ public class ComponentBundlerTask extends Task
|
||||
addTileSetRuleSet(digester, new UniformTileSetRuleSet("/uniformTileset"));
|
||||
|
||||
|
||||
HashMap actsets = new ActionMap();
|
||||
HashMap<String, TileSet> actsets = new ActionMap();
|
||||
digester.push(actsets);
|
||||
|
||||
try {
|
||||
@@ -484,7 +485,7 @@ public class ComponentBundlerTask extends Task
|
||||
}
|
||||
|
||||
/** Used when parsing action tilesets. */
|
||||
public static class ActionMap extends HashMap
|
||||
public static class ActionMap extends HashMap<String, TileSet>
|
||||
{
|
||||
public void setName (String name) {
|
||||
_name = name;
|
||||
@@ -546,13 +547,13 @@ public class ComponentBundlerTask extends Task
|
||||
}
|
||||
|
||||
protected static class HashMapIDBroker
|
||||
extends HashMap implements ComponentIDBroker
|
||||
extends HashMap<Tuple<String, String>, Integer> implements ComponentIDBroker
|
||||
{
|
||||
public int getComponentID (String cclass, String cname)
|
||||
throws PersistenceException
|
||||
{
|
||||
Tuple key = new Tuple(cclass, cname);
|
||||
Integer cid = (Integer)get(key);
|
||||
Tuple<String, String> key = new Tuple<String, String>(cclass, cname);
|
||||
Integer cid = get(key);
|
||||
if (cid == null) {
|
||||
cid = Integer.valueOf(++_nextCID);
|
||||
put(key, cid);
|
||||
@@ -580,11 +581,11 @@ public class ComponentBundlerTask extends Task
|
||||
bout.newLine();
|
||||
|
||||
// write out the keys and values
|
||||
ComparableArrayList lines = new ComparableArrayList();
|
||||
Iterator keys = keySet().iterator();
|
||||
ComparableArrayList<String> lines = new ComparableArrayList<String>();
|
||||
Iterator<Tuple<String, String>> keys = keySet().iterator();
|
||||
while (keys.hasNext()) {
|
||||
Tuple key = (Tuple)keys.next();
|
||||
Integer value = (Integer)get(key);
|
||||
Tuple<String, String> key = keys.next();
|
||||
Integer value = get(key);
|
||||
String line = key.left + SEP_STR + key.right + SEP_STR + value;
|
||||
lines.add(line);
|
||||
}
|
||||
@@ -595,7 +596,7 @@ public class ComponentBundlerTask extends Task
|
||||
// now write it to the file
|
||||
int lcount = lines.size();
|
||||
for (int ii = 0; ii < lcount; ii++) {
|
||||
String line = (String)lines.get(ii);
|
||||
String line = lines.get(ii);
|
||||
bout.write(line, 0, line.length());
|
||||
bout.newLine();
|
||||
}
|
||||
@@ -626,7 +627,7 @@ public class ComponentBundlerTask extends Task
|
||||
String cname = line.substring(0, sidx);
|
||||
line = line.substring(sidx + SEP_STR.length());
|
||||
try {
|
||||
put(new Tuple(cclass, cname), Integer.valueOf(line));
|
||||
put(new Tuple<String, String>(cclass, cname), Integer.valueOf(line));
|
||||
} catch (NumberFormatException nfe) {
|
||||
String err = "Malformed line, invalid code '" + orig + "'";
|
||||
throw new IOException(err);
|
||||
|
||||
@@ -23,7 +23,6 @@ package com.threerings.cast.bundle.tools;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import com.samskivert.util.HashIntMap;
|
||||
@@ -51,19 +50,19 @@ public class DumpBundle
|
||||
try {
|
||||
ResourceBundle bundle = new FileResourceBundle(file);
|
||||
|
||||
HashMap actions = (HashMap)BundleUtil.loadObject(
|
||||
HashMap<?, ?> actions = (HashMap<?, ?>)BundleUtil.loadObject(
|
||||
bundle, BundleUtil.ACTIONS_PATH, false);
|
||||
dumpTable("actions: ", actions);
|
||||
|
||||
HashMap actionSets = (HashMap)BundleUtil.loadObject(
|
||||
HashMap<?, ?> actionSets = (HashMap<?, ?>)BundleUtil.loadObject(
|
||||
bundle, BundleUtil.ACTION_SETS_PATH, false);
|
||||
dumpTable("actionSets: ", actionSets);
|
||||
|
||||
HashMap classes = (HashMap)BundleUtil.loadObject(
|
||||
HashMap<?, ?> classes = (HashMap<?, ?>)BundleUtil.loadObject(
|
||||
bundle, BundleUtil.CLASSES_PATH, false);
|
||||
dumpTable("classes: ", classes);
|
||||
|
||||
HashIntMap comps = (HashIntMap)BundleUtil.loadObject(
|
||||
HashIntMap<?> comps = (HashIntMap<?>)BundleUtil.loadObject(
|
||||
bundle, BundleUtil.COMPONENTS_PATH, false);
|
||||
dumpTable("components: ", comps);
|
||||
|
||||
@@ -75,11 +74,10 @@ public class DumpBundle
|
||||
}
|
||||
}
|
||||
|
||||
protected static void dumpTable (String prefix, Map table)
|
||||
protected static void dumpTable (String prefix, Map<?, ?> table)
|
||||
{
|
||||
if (table != null) {
|
||||
Iterator iter = table.entrySet().iterator();
|
||||
System.out.println(prefix + StringUtil.toString(iter));
|
||||
System.out.println(prefix + StringUtil.toString(table.entrySet().iterator()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.zip.Deflater;
|
||||
@@ -98,10 +99,10 @@ public class MetadataBundlerTask extends Task
|
||||
try {
|
||||
|
||||
// parse our metadata
|
||||
Tuple tuple = parseActions();
|
||||
HashMap actions = (HashMap)tuple.left;
|
||||
HashMap actionSets = (HashMap)tuple.right;
|
||||
HashMap classes = parseClasses();
|
||||
Tuple<Map<String, ActionSequence>, Map<String, TileSet>> tuple = parseActions();
|
||||
Map<String, ActionSequence> actions = tuple.left;
|
||||
Map<String, TileSet> actionSets = tuple.right;
|
||||
Map<String, ComponentClass> classes = parseClasses();
|
||||
|
||||
fout = createOutputStream(_target);
|
||||
|
||||
@@ -174,7 +175,7 @@ public class MetadataBundlerTask extends Task
|
||||
digester.addSetNext(ruleSet.getPath(), "add", Object.class.getName());
|
||||
}
|
||||
|
||||
protected Tuple parseActions ()
|
||||
protected Tuple<Map<String, ActionSequence>, Map<String, TileSet>> parseActions ()
|
||||
throws BuildException
|
||||
{
|
||||
// scan through the XML once to read the actions
|
||||
@@ -183,13 +184,13 @@ public class MetadataBundlerTask extends Task
|
||||
arules.setPrefix("actions");
|
||||
digester.addRuleSet(arules);
|
||||
digester.addSetNext("actions" + ActionRuleSet.ACTION_PATH, "add", Object.class.getName());
|
||||
ArrayList actlist = parseList(digester, _actionDef);
|
||||
ArrayList<?> actlist = parseList(digester, _actionDef);
|
||||
|
||||
// now go through a second time reading the tileset info
|
||||
digester = new Digester();
|
||||
addTileSetRuleSet(digester, new SwissArmyTileSetRuleSet());
|
||||
addTileSetRuleSet(digester, new UniformTileSetRuleSet("/uniformTileset"));
|
||||
ArrayList setlist = parseList(digester, _actionDef);
|
||||
ArrayList<?> setlist = parseList(digester, _actionDef);
|
||||
|
||||
// sanity check
|
||||
if (actlist.size() != setlist.size()) {
|
||||
@@ -199,8 +200,8 @@ public class MetadataBundlerTask extends Task
|
||||
}
|
||||
|
||||
// now create our mappings
|
||||
HashMap actmap = new HashMap();
|
||||
HashMap setmap = new HashMap();
|
||||
Map<String, ActionSequence> actmap = new HashMap<String, ActionSequence>();
|
||||
Map<String, TileSet> setmap = new HashMap<String, TileSet>();
|
||||
|
||||
// create the action map
|
||||
for (int i = 0; i < setlist.size(); i++) {
|
||||
@@ -218,10 +219,10 @@ public class MetadataBundlerTask extends Task
|
||||
setmap.put(act.name, set);
|
||||
}
|
||||
|
||||
return new Tuple(actmap, setmap);
|
||||
return new Tuple<Map<String, ActionSequence>, Map<String, TileSet>>(actmap, setmap);
|
||||
}
|
||||
|
||||
protected HashMap parseClasses ()
|
||||
protected Map<String, ComponentClass> parseClasses ()
|
||||
throws BuildException
|
||||
{
|
||||
// load up our action and class info
|
||||
@@ -234,8 +235,8 @@ public class MetadataBundlerTask extends Task
|
||||
digester.addSetNext("classes" + ClassRuleSet.CLASS_PATH,
|
||||
"add", Object.class.getName());
|
||||
|
||||
ArrayList setlist = parseList(digester, _classDef);
|
||||
HashMap clmap = new HashMap();
|
||||
ArrayList<?> setlist = parseList(digester, _classDef);
|
||||
Map<String, ComponentClass> clmap = new HashMap<String, ComponentClass>();
|
||||
|
||||
// create the action map
|
||||
for (int i = 0; i < setlist.size(); i++) {
|
||||
@@ -246,14 +247,14 @@ public class MetadataBundlerTask extends Task
|
||||
return clmap;
|
||||
}
|
||||
|
||||
protected ArrayList parseList (Digester digester, String path)
|
||||
protected ArrayList<?> parseList (Digester digester, String path)
|
||||
throws BuildException
|
||||
{
|
||||
try {
|
||||
FileInputStream fin = new FileInputStream(path);
|
||||
BufferedInputStream bin = new BufferedInputStream(fin);
|
||||
|
||||
ArrayList setlist = new ArrayList();
|
||||
ArrayList<Object> setlist = new ArrayList<Object>();
|
||||
digester.push(setlist);
|
||||
|
||||
// now fire up the digester to parse the stream
|
||||
|
||||
Reference in New Issue
Block a user