Implemented enumerateTileSetIds(); also added sanity check when scanning

the resource bundles at construct time.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@656 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-11-29 00:12:42 +00:00
parent 0a5f5794e8
commit 38a538a446
@@ -1,5 +1,5 @@
//
// $Id: BundledTileSetRepository.java,v 1.2 2001/11/21 02:42:15 mdb Exp $
// $Id: BundledTileSetRepository.java,v 1.3 2001/11/29 00:12:42 mdb Exp $
package com.threerings.media.tile.bundle;
@@ -50,6 +50,15 @@ public class BundledTileSetRepository
// tileset bundles
ResourceBundle[] rbundles = rmgr.getResourceSet(name);
// sanity check
if (rbundles == null) {
Log.warning("Unable to fetch tileset resource set " +
"[name=" + name + "]. Perhaps it's not defined " +
"in the resource manager config?");
_bundles = new TileSetBundle[0];
return;
}
// iterate over the resource bundles in the set, loading up the
// tileset bundles in each resource bundle
ArrayList tbundles = new ArrayList();;
@@ -68,6 +77,7 @@ public class BundledTileSetRepository
Log.warning("Unable to load tileset bundles from resource " +
"bundle [rbundle=" + rbundles[i] +
", error=" + e + "].");
Log.logStackTrace(e);
}
}
@@ -76,6 +86,22 @@ public class BundledTileSetRepository
tbundles.toArray(_bundles);
}
// documentation inherited
public Iterator enumerateTileSetIds ()
throws PersistenceException
{
return new CompoundIterator(new IteratorProvider() {
public Iterator nextIterator () {
if (_bidx < _bundles.length) {
return _bundles[_bidx++].enumerateTileSetIds();
} else {
return null;
}
}
protected int _bidx = 0;
});
}
// documentation inherited
public Iterator enumerateTileSets ()
throws PersistenceException