com.threerings.media.tile.tools.xml
Class XMLTileSetParser

java.lang.Object
  extended by com.threerings.media.tile.tools.xml.XMLTileSetParser

public class XMLTileSetParser
extends Object

Parse an XML tileset description file and construct tileset objects for each valid description. Does not currently perform validation on the input XML stream, though the parsing code assumes the XML document is well-formed.


Constructor Summary
XMLTileSetParser()
          Constructs an xml tile set parser.
 
Method Summary
 void addRuleSet(String prefix, TileSetRuleSet ruleset)
          Adds a ruleset to be used when parsing tiles.
 void loadTileSets(File file, Map<String,TileSet> tilesets)
          Loads all of the tilesets specified in the supplied XML tileset description file and places them into the supplied map indexed by tileset name.
 void loadTileSets(InputStream source, Map<String,TileSet> tilesets)
          Loads all of the tilesets specified in the supplied XML tileset description file and places them into the supplied map indexed by tileset name.
 void loadTileSets(String path, Map<String,TileSet> tilesets)
          Loads all of the tilesets specified in the supplied XML tileset description file and places them into the supplied map indexed by tileset name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLTileSetParser

public XMLTileSetParser()
Constructs an xml tile set parser.

Method Detail

addRuleSet

public void addRuleSet(String prefix,
                       TileSetRuleSet ruleset)
Adds a ruleset to be used when parsing tiles. This should be an instance of a class derived from TileSetRuleSet. The prefix will be used to configure the ruleset so that it matches elements at a particular point in the XML hierarchy. For example:
 _parser.addRuleSet("tilesets", new UniformTileSetRuleSet());
 


loadTileSets

public void loadTileSets(String path,
                         Map<String,TileSet> tilesets)
                  throws IOException
Loads all of the tilesets specified in the supplied XML tileset 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.

Parameters:
path - a path, relative to the classpath, at which the tileset definition file can be found.
tilesets - the map into which the tilesets will be placed, indexed by tileset name.
Throws:
IOException

loadTileSets

public void loadTileSets(File file,
                         Map<String,TileSet> tilesets)
                  throws IOException
Loads all of the tilesets specified in the supplied XML tileset 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.

Parameters:
file - the file in which the tileset definition file can be found.
tilesets - the map into which the tilesets will be placed, indexed by tileset name.
Throws:
IOException

loadTileSets

public void loadTileSets(InputStream source,
                         Map<String,TileSet> tilesets)
                  throws IOException
Loads all of the tilesets specified in the supplied XML tileset 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.

Parameters:
source - an input stream from which the tileset definition file can be read.
tilesets - the map into which the tilesets will be placed, indexed by tileset name.
Throws:
IOException


Copyright © 2011. All Rights Reserved.