A healthy splash of google-collections

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@822 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Dave Hoover
2009-05-23 01:31:14 +00:00
parent a20117d922
commit d2b9e2ebb9
52 changed files with 246 additions and 191 deletions
@@ -24,6 +24,8 @@ package com.threerings.media.tile.bundle;
import java.util.HashMap;
import java.util.Iterator;
import com.google.common.collect.Maps;
import com.samskivert.io.PersistenceException;
import com.samskivert.util.HashIntMap;
import com.samskivert.util.IntMap;
@@ -74,7 +76,7 @@ public class BundledTileSetRepository
}
/**
* Initializes our bundles,
* Initializes our bundles,
*/
protected void initBundles (ResourceManager rmgr, String name)
{
@@ -91,12 +93,12 @@ public class BundledTileSetRepository
}
HashIntMap<TileSet> idmap = new HashIntMap<TileSet>();
HashMap<String, Integer> namemap = new HashMap<String, Integer>();
HashMap<String, Integer> namemap = Maps.newHashMap();
// iterate over the resource bundles in the set, loading up the
// tileset bundles in each resource bundle
for (int i = 0; i < rbundles.length; i++) {
addBundle(idmap, namemap, rbundles[i]);
for (ResourceBundle rbundle : rbundles) {
addBundle(idmap, namemap, rbundle);
}
// fill in our bundles array and wake up any waiters
@@ -43,6 +43,8 @@ import org.xml.sax.SAXException;
import org.apache.commons.digester.Digester;
import org.apache.commons.io.IOUtils;
import com.google.common.collect.Lists;
import com.samskivert.io.PersistenceException;
import com.samskivert.util.HashIntMap;
@@ -137,7 +139,7 @@ public class TileSetBundler
Digester digester = new Digester();
// push our mappings array onto the stack
ArrayList<Mapping> mappings = new ArrayList<Mapping>();
ArrayList<Mapping> mappings = Lists.newArrayList();
digester.push(mappings);
// create a mapping object for each mapping entry and append it to
@@ -232,7 +234,7 @@ public class TileSetBundler
{
// stick an array list on the top of the stack into which we will
// collect parsed tilesets
ArrayList<TileSet> sets = new ArrayList<TileSet>();
ArrayList<TileSet> sets = Lists.newArrayList();
_digester.push(sets);
// parse the tilesets
@@ -367,7 +369,7 @@ public class TileSetBundler
// write all of the image files to the bundle, converting the
// tilesets to trimmed tilesets in the process
Iterator<Integer> iditer = bundle.enumerateTileSetIds();
// Store off the updated TileSets in a separate Map so we can wait to change the
// bundle till we're done iterating.
HashIntMap<TileSet> toUpdate = new HashIntMap<TileSet>();
@@ -31,6 +31,8 @@ import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import com.google.common.collect.Lists;
import com.threerings.media.tile.tools.MapFileTileSetIDBroker;
/**
@@ -92,8 +94,8 @@ public class TileSetBundlerTask extends Task
File fromDir = fs.getDir(getProject());
String[] srcFiles = ds.getIncludedFiles();
for (int f = 0; f < srcFiles.length; f++) {
cfile = new File(fromDir, srcFiles[f]);
for (String srcFile : srcFiles) {
cfile = new File(fromDir, srcFile);
// figure out the bundle file based on the definition
// file
@@ -158,5 +160,5 @@ public class TileSetBundlerTask extends Task
protected File _mapfile;
/** A list of filesets that contain tileset bundle definitions. */
protected ArrayList<FileSet> _filesets = new ArrayList<FileSet>();
protected ArrayList<FileSet> _filesets = Lists.newArrayList();
}
@@ -32,6 +32,8 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import com.google.common.collect.Maps;
import com.samskivert.io.PersistenceException;
import com.samskivert.util.QuickSort;
@@ -60,14 +62,14 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker
_nextTileSetID = readInt(bin);
_storedTileSetID = _nextTileSetID;
// read in our mappings
_map = new HashMap<String, Integer>();
_map = Maps.newHashMap();
readMapFile(bin, _map);
bin.close();
} catch (FileNotFoundException fnfe) {
// create a blank map if our map file doesn't exist
_map = new HashMap<String, Integer>();
_map = Maps.newHashMap();
} catch (Exception e) {
// other errors are more fatal
@@ -170,8 +172,8 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker
lines[ii] = key + SEP_STR + value;
}
QuickSort.sort(lines);
for (int ii = 0; ii < lines.length; ii++) {
bout.write(lines[ii], 0, lines[ii].length());
for (String line : lines) {
bout.write(line, 0, line.length());
bout.newLine();
}
bout.flush();
@@ -21,7 +21,6 @@
package com.threerings.media.tile.tools.xml;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -35,6 +34,8 @@ import org.xml.sax.SAXException;
import org.apache.commons.digester.Digester;
import com.google.common.collect.Lists;
import com.samskivert.util.ConfigUtil;
import com.samskivert.xml.ValidatedSetNextRule;
@@ -144,7 +145,7 @@ public class XMLTileSetParser
{
// stick an array list on the top of the stack for collecting
// parsed tilesets
List<TileSet> setlist = new ArrayList<TileSet>();
List<TileSet> setlist = Lists.newArrayList();
_digester.push(setlist);
// now fire up the digester to parse the stream