com.threerings.media.tile.tools
Class MapFileTileSetIDBroker

java.lang.Object
  extended by com.threerings.media.tile.tools.MapFileTileSetIDBroker
All Implemented Interfaces:
TileSetIDBroker

public class MapFileTileSetIDBroker
extends Object
implements TileSetIDBroker

Stores a set of tileset name to id mappings in a map file.


Constructor Summary
MapFileTileSetIDBroker(File mapfile)
          Creates a broker that will use the specified file as its persistent store.
 
Method Summary
 void commit()
          When the user of a tilset id broker is done obtaining tileset ids, it must call this method to give the tileset id broker an opportunity to flush any newly created tileset ids back to its persistent store.
 int getTileSetID(String tileSetName)
          Returns the unique identifier for the named tileset.
static void readMapFile(BufferedReader bin, HashMap<String,Integer> map)
          Reads in a mapping from strings to integers, which should have been written via writeMapFile(java.io.BufferedWriter, java.util.HashMap).
 boolean tileSetMapped(String tileSetName)
          Returns true if the specified tileset name is currently mapped to some value by this broker.
static void writeMapFile(BufferedWriter bout, HashMap<String,Integer> map)
          Writes out a mapping from strings to integers in a manner that can be read back in via readMapFile(java.io.BufferedReader, java.util.HashMap).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapFileTileSetIDBroker

public MapFileTileSetIDBroker(File mapfile)
                       throws PersistenceException
Creates a broker that will use the specified file as its persistent store. The persistent store will be created if it does not yet exist.

Throws:
PersistenceException
Method Detail

getTileSetID

public int getTileSetID(String tileSetName)
                 throws PersistenceException
Description copied from interface: TileSetIDBroker
Returns the unique identifier for the named tileset. If no identifier has yet been assigned to the specified named tileset, one should be assigned and returned.

Specified by:
getTileSetID in interface TileSetIDBroker
Throws:
PersistenceException - thrown if an error occurs communicating with the underlying persistence mechanism used to store the name to id mappings.

tileSetMapped

public boolean tileSetMapped(String tileSetName)
                      throws PersistenceException
Description copied from interface: TileSetIDBroker
Returns true if the specified tileset name is currently mapped to some value by this broker.

Specified by:
tileSetMapped in interface TileSetIDBroker
Throws:
PersistenceException - thrown if an error occurs communicating with the underlying persistence mechanism used to store the name to id mappings.

commit

public void commit()
            throws PersistenceException
Description copied from interface: TileSetIDBroker
When the user of a tilset id broker is done obtaining tileset ids, it must call this method to give the tileset id broker an opportunity to flush any newly created tileset ids back to its persistent store.

Specified by:
commit in interface TileSetIDBroker
Throws:
PersistenceException

readMapFile

public static void readMapFile(BufferedReader bin,
                               HashMap<String,Integer> map)
                        throws IOException
Reads in a mapping from strings to integers, which should have been written via writeMapFile(java.io.BufferedWriter, java.util.HashMap).

Throws:
IOException

writeMapFile

public static void writeMapFile(BufferedWriter bout,
                                HashMap<String,Integer> map)
                         throws IOException
Writes out a mapping from strings to integers in a manner that can be read back in via readMapFile(java.io.BufferedReader, java.util.HashMap).

Throws:
IOException


Copyright © 2011. All Rights Reserved.