Package VASSAL.tools

Class UniqueIdManager

java.lang.Object
VASSAL.tools.UniqueIdManager
All Implemented Interfaces:
ValidityChecker

public class UniqueIdManager extends Object implements ValidityChecker
A class for assigning unique identifiers to objects. Identifiers will be of the form prefix#, where prefix is specified at initialization and the # is an increasing digit. Components will have the same ID provided they are loaded in the same order. Unfortunately, this approach is flawed. If a module is edited, saved games from previous versions can become broken. Worse, two players with different extensions loaded could have incompatible behavior. The preferred way to have unique identifiers is to allow the user to provide names and use a ValidityChecker to ensure that the names are unique. This class provides some support for using this approach while providing backward compatibility with old saved games and modules. Usage: an UniqueIdManager.Identifyable instance invokes add(VASSAL.tools.UniqueIdManager.Identifyable), typically during the Buildable.build(org.w3c.dom.Element) method. Classes can use the getIdentifier(VASSAL.tools.UniqueIdManager.Identifyable) method to look up an identifier for that instance, and can use findInstance(java.lang.String) to look up a component by id.