Clean up some possible nulls to quiet Eclipse

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@641 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Charlie Groves
2008-08-21 01:50:06 +00:00
parent 99fc1ddbf7
commit 81a2d3d104
3 changed files with 23 additions and 15 deletions
@@ -91,42 +91,46 @@ public class BundledComponentRepository
// first we obtain the resource set from whence will come our bundles // first we obtain the resource set from whence will come our bundles
ResourceBundle[] rbundles = rmgr.getResourceSet(name); ResourceBundle[] rbundles = rmgr.getResourceSet(name);
if (rbundles == null) {
// Couldn't find a bundle with that name, so just make empty maps for safe enumerating
fillInWithEmptyMaps();
return;
}
// look for our metadata info in each of the bundles // look for our metadata info in each of the bundles
try { try {
int rcount = (rbundles == null) ? 0 : rbundles.length; for (ResourceBundle rbundle : rbundles) {
for (int i = 0; i < rcount; i++) {
if (_actions == null) { if (_actions == null) {
@SuppressWarnings("unchecked") Map<String, ActionSequence> amap = @SuppressWarnings("unchecked") Map<String, ActionSequence> amap =
(Map<String, ActionSequence>)BundleUtil.loadObject( (Map<String, ActionSequence>)BundleUtil.loadObject(
rbundles[i], BundleUtil.ACTIONS_PATH, true); rbundle, BundleUtil.ACTIONS_PATH, true);
_actions = amap; _actions = amap;
} }
if (_actionSets == null) { if (_actionSets == null) {
@SuppressWarnings("unchecked") Map<String, TileSet> asets = @SuppressWarnings("unchecked") Map<String, TileSet> asets =
(Map<String, TileSet>)BundleUtil.loadObject( (Map<String, TileSet>)BundleUtil.loadObject(
rbundles[i], BundleUtil.ACTION_SETS_PATH, true); rbundle, BundleUtil.ACTION_SETS_PATH, true);
_actionSets = asets; _actionSets = asets;
} }
if (_classes == null) { if (_classes == null) {
@SuppressWarnings("unchecked") Map<String, ComponentClass> cmap = @SuppressWarnings("unchecked") Map<String, ComponentClass> cmap =
(Map<String, ComponentClass>)BundleUtil.loadObject( (Map<String, ComponentClass>)BundleUtil.loadObject(
rbundles[i], BundleUtil.CLASSES_PATH, true); rbundle, BundleUtil.CLASSES_PATH, true);
_classes = cmap; _classes = cmap;
} }
} }
// now go back and load up all of the component information // now go back and load up all of the component information
for (int i = 0; i < rcount; i++) { for (ResourceBundle rbundle : rbundles) {
@SuppressWarnings("unchecked") IntMap<Tuple<String, String>> comps = @SuppressWarnings("unchecked") IntMap<Tuple<String, String>> comps =
(IntMap<Tuple<String, String>>)BundleUtil.loadObject( (IntMap<Tuple<String, String>>)BundleUtil.loadObject(
rbundles[i], BundleUtil.COMPONENTS_PATH, true); rbundle, BundleUtil.COMPONENTS_PATH, true);
if (comps == null) { if (comps == null) {
continue; continue;
} }
// create a frame provider for this bundle // create a frame provider for this bundle
FrameProvider fprov = new ResourceBundleProvider(_imgr, rbundles[i]); FrameProvider fprov = new ResourceBundleProvider(_imgr, rbundle);
// now create char. component instances for each component in the serialized table // now create char. component instances for each component in the serialized table
Iterator<Integer> iter = comps.keySet().iterator(); Iterator<Integer> iter = comps.keySet().iterator();
@@ -144,6 +148,11 @@ public class BundledComponentRepository
// if we failed to load our classes or actions, create empty hashtables so that we can // if we failed to load our classes or actions, create empty hashtables so that we can
// safely enumerate our emptiness // safely enumerate our emptiness
fillInWithEmptyMaps();
}
protected void fillInWithEmptyMaps(){
if (_actions == null) { if (_actions == null) {
_actions = Maps.newHashMap(); _actions = Maps.newHashMap();
} }
@@ -364,8 +373,8 @@ public class BundledComponentRepository
} }
return actionPath; return actionPath;
} }
protected String makePath(CharacterComponent component, String action, String type) protected String makePath(CharacterComponent component, String action, String type)
{ {
String imgpath = action; String imgpath = action;
if (type != null) { if (type != null) {
@@ -57,9 +57,8 @@ public class BackedVolatileMirage extends VolatileMirage
@Override @Override
protected void refreshVolatileImage () protected void refreshVolatileImage ()
{ {
Graphics gfx = null; Graphics gfx = _image.getGraphics();
try { try {
gfx = _image.getGraphics();
gfx.drawImage(_source, -_bounds.x, -_bounds.y, null); gfx.drawImage(_source, -_bounds.x, -_bounds.y, null);
} catch (Exception e) { } catch (Exception e) {
@@ -25,7 +25,7 @@ import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
/** /**
* Tests the {@link Direction} class. * Tests the {@link DirectionUtil} class.
*/ */
public class DirectionTest extends TestCase public class DirectionTest extends TestCase
implements DirectionCodes implements DirectionCodes