From 38a538a4460bc0f48545400f59f1c87a2c78224e Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 29 Nov 2001 00:12:42 +0000 Subject: [PATCH] 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 --- .../tile/bundle/BundledTileSetRepository.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/media/tile/bundle/BundledTileSetRepository.java b/src/java/com/threerings/media/tile/bundle/BundledTileSetRepository.java index 810d65086..8b7d932e7 100644 --- a/src/java/com/threerings/media/tile/bundle/BundledTileSetRepository.java +++ b/src/java/com/threerings/media/tile/bundle/BundledTileSetRepository.java @@ -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