Some code hygiene.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@592 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Michael Bayne
2008-08-01 14:39:57 +00:00
parent 786dd4f7ff
commit 60622c3590
4 changed files with 37 additions and 41 deletions
@@ -212,7 +212,7 @@ public abstract class AbstractMedia
* Queues the supplied notification up to be dispatched to this
* abstract media's observers.
*/
public void queueNotification (ObserverList.ObserverOp amop)
public void queueNotification (ObserverList.ObserverOp<Object> amop)
{
if (_observers != null) {
if (_mgr != null) {
@@ -330,7 +330,7 @@ public abstract class AbstractMedia
protected void addObserver (Object obs)
{
if (_observers == null) {
_observers = new ObserverList(ObserverList.FAST_UNSAFE_NOTIFY);
_observers = ObserverList.newFastUnsafe();
}
_observers.add(obs);
}
@@ -376,7 +376,7 @@ public abstract class AbstractMedia
protected AbstractMediaManager _mgr;
/** Our observers. */
protected ObserverList _observers = null;
protected ObserverList<Object> _observers = null;
/** The tick stamp associated with our first call to {@link #tick}.
* This is set up automatically in {@link #willStart}. */
@@ -75,7 +75,7 @@ public class ColorPository implements Serializable
public int defaultId;
/** A table of target colors included in this class. */
public HashIntMap colors = new HashIntMap();
public HashIntMap<ColorRecord> colors = new HashIntMap<ColorRecord>();
/** Used when parsing the color definitions. */
public void addColor (ColorRecord record)
@@ -114,9 +114,7 @@ public class ColorPository implements Serializable
}
// Look for name matches among all colors
Iterator iter = colors.values().iterator();
while (iter.hasNext()) {
ColorRecord color = (ColorRecord)iter.next();
for (ColorRecord color : colors.values()) {
if (color.name.equalsIgnoreCase(name)) {
return color.colorId;
}
@@ -132,16 +130,13 @@ public class ColorPository implements Serializable
{
// figure out our starter ids if we haven't already
if (_starters == null) {
ArrayList list = new ArrayList();
Iterator iter = colors.values().iterator();
while (iter.hasNext()) {
ColorRecord color = (ColorRecord)iter.next();
ArrayList<ColorRecord> list = new ArrayList<ColorRecord>();
for (ColorRecord color : colors.values()) {
if (color.starter) {
list.add(color);
}
}
_starters = (ColorRecord[])
list.toArray(new ColorRecord[list.size()]);
_starters = list.toArray(new ColorRecord[list.size()]);
}
// sanity check
@@ -161,7 +156,7 @@ public class ColorPository implements Serializable
*/
public ColorRecord getDefault ()
{
return (ColorRecord) colors.get(defaultId);
return colors.get(defaultId);
}
@Override
@@ -249,7 +244,7 @@ public class ColorPository implements Serializable
/**
* Returns an iterator over all color classes in this pository.
*/
public Iterator enumerateClasses ()
public Iterator<ClassRecord> enumerateClasses ()
{
return _classes.values().iterator();
}
@@ -268,9 +263,9 @@ public class ColorPository implements Serializable
// create the array
ColorRecord[] crecs = new ColorRecord[record.colors.size()];
Iterator iter = record.colors.values().iterator();
Iterator<ColorRecord> iter = record.colors.values().iterator();
for (int i = 0; iter.hasNext(); i++) {
crecs[i] = ((ColorRecord)iter.next());
crecs[i] = iter.next();
}
return crecs;
}
@@ -288,9 +283,9 @@ public class ColorPository implements Serializable
}
int[] cids = new int[record.colors.size()];
Iterator crecs = record.colors.values().iterator();
Iterator<ColorRecord> crecs = record.colors.values().iterator();
for (int i = 0; crecs.hasNext(); i++) {
cids[i] = ((ColorRecord)crecs.next()).colorId;
cids[i] = crecs.next().colorId;
}
return cids;
}
@@ -340,7 +335,7 @@ public class ColorPository implements Serializable
{
ClassRecord crec = getClassRecord(className);
if (crec != null) {
ColorRecord color = (ColorRecord)crec.colors.get(colorId);
ColorRecord color = crec.colors.get(colorId);
if (color != null) {
return color.getColorization();
}
@@ -363,7 +358,7 @@ public class ColorPository implements Serializable
return null;
}
ColorRecord color = (ColorRecord)crec.colors.get(colorId);
ColorRecord color = crec.colors.get(colorId);
if (color != null) {
return color.getColorization();
}
@@ -377,9 +372,9 @@ public class ColorPository implements Serializable
*/
public ClassRecord getClassRecord (String className)
{
Iterator iter = _classes.values().iterator();
Iterator<ClassRecord> iter = _classes.values().iterator();
while (iter.hasNext()) {
ClassRecord crec = (ClassRecord)iter.next();
ClassRecord crec = iter.next();
if (crec.name.equals(className)) {
return crec;
}
@@ -394,7 +389,7 @@ public class ColorPository implements Serializable
*/
public ColorRecord getColorRecord (int classId, int colorId)
{
ClassRecord record = (ClassRecord)_classes.get(classId);
ClassRecord record = _classes.get(classId);
if (record == null) {
// if they request color class zero, we assume they're just
// decoding a blank colorprint, otherwise we complain
@@ -406,7 +401,7 @@ public class ColorPository implements Serializable
}
return null;
}
return (ColorRecord)record.colors.get(colorId);
return record.colors.get(colorId);
}
/**
@@ -430,7 +425,7 @@ public class ColorPository implements Serializable
return null;
}
return (ColorRecord)record.colors.get(colorId);
return record.colors.get(colorId);
}
/**
@@ -491,7 +486,7 @@ public class ColorPository implements Serializable
}
/** Our mapping from class names to class records. */
protected HashIntMap _classes = new HashIntMap();
protected HashIntMap<ClassRecord> _classes = new HashIntMap<ClassRecord>();
/** Increase this value when object's serialized state is impacted by
* a class change (modification of fields, inheritance). */
@@ -37,13 +37,13 @@ public interface TileSetRepository
* Returns an iterator over the identifiers of all {@link TileSet}
* objects available.
*/
public Iterator enumerateTileSetIds ()
public Iterator<Integer> enumerateTileSetIds ()
throws PersistenceException;
/**
* Returns an iterator over all {@link TileSet} objects available.
*/
public Iterator enumerateTileSets ()
public Iterator<TileSet> enumerateTileSets ()
throws PersistenceException;
/**
@@ -27,7 +27,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.digester.Digester;
import org.xml.sax.SAXException;
@@ -83,16 +84,16 @@ public class XMLTileSetParser
/**
* Loads all of the tilesets specified in the supplied XML tileset
* description file and places them into the supplied hashmap indexed
* description file and places them into the supplied map indexed
* by tileset name. This method is not reentrant, so don't go calling
* it from multiple threads.
*
* @param path a path, relative to the classpath, at which the tileset
* definition file can be found.
* @param tilesets the hashmap into which the tilesets will be placed,
* @param tilesets the map into which the tilesets will be placed,
* indexed by tileset name.
*/
public void loadTileSets (String path, HashMap tilesets)
public void loadTileSets (String path, Map<String, TileSet> tilesets)
throws IOException
{
// get an input stream for this XML file
@@ -109,16 +110,16 @@ public class XMLTileSetParser
/**
* Loads all of the tilesets specified in the supplied XML tileset
* description file and places them into the supplied hashmap indexed
* description file and places them into the supplied map indexed
* by tileset name. This method is not reentrant, so don't go calling
* it from multiple threads.
*
* @param file the file in which the tileset definition file can be
* found.
* @param tilesets the hashmap into which the tilesets will be placed,
* @param tilesets the map into which the tilesets will be placed,
* indexed by tileset name.
*/
public void loadTileSets (File file, HashMap tilesets)
public void loadTileSets (File file, Map<String, TileSet> tilesets)
throws IOException
{
// load up the tilesets
@@ -127,21 +128,21 @@ public class XMLTileSetParser
/**
* Loads all of the tilesets specified in the supplied XML tileset
* description file and places them into the supplied hashmap indexed
* description file and places them into the supplied map indexed
* by tileset name. This method is not reentrant, so don't go calling
* it from multiple threads.
*
* @param source an input stream from which the tileset definition
* file can be read.
* @param tilesets the hashmap into which the tilesets will be placed,
* @param tilesets the map into which the tilesets will be placed,
* indexed by tileset name.
*/
public void loadTileSets (InputStream source, HashMap tilesets)
public void loadTileSets (InputStream source, Map<String, TileSet> tilesets)
throws IOException
{
// stick an array list on the top of the stack for collecting
// parsed tilesets
ArrayList setlist = new ArrayList();
List<TileSet> setlist = new ArrayList<TileSet>();
_digester.push(setlist);
// now fire up the digester to parse the stream
@@ -153,7 +154,7 @@ public class XMLTileSetParser
// stick the tilesets from the list into the hashtable
for (int i = 0; i < setlist.size(); i++) {
TileSet set = (TileSet)setlist.get(i);
TileSet set = setlist.get(i);
if (set.getName() == null) {
log.warning("Tileset did not receive name during " +
"parsing process [set=" + set + "].");