uk.me.nxg.unity
Class UnitDefinitionMap

java.lang.Object
  extended by uk.me.nxg.unity.UnitDefinitionMap
All Implemented Interfaces:
Serializable

public class UnitDefinitionMap
extends Object
implements Serializable

Provides a mapping from unit abbreviations to unit definitions.

This is a singleton class, so clients must first obtain the instance of the class using getInstance().

See Also:
Serialized Form

Method Summary
static UnitDefinitionMap getInstance()
          Obtain an instance of the unit-definition map.
 Set<String> keySet()
          Obtains all of the unit abbreviations known to this map.
 UnitDefinition lookup(String k)
          Looks up the unit which corresponds to a unit abbreviation
static void persist(Map<String,UnitDefinition> m, File persistenceFile)
          Persist a mapping of unit abbreviations to unit definitions.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

persist

public static void persist(Map<String,UnitDefinition> m,
                           File persistenceFile)
                    throws IOException
Persist a mapping of unit abbreviations to unit definitions. The mapping is written to a Java serialization file, from which it may subsequently be re-read by an instance of this class.

This method is public, but is not not expected to be used by clients; it is used only when building this package. FIXME: this is a poor design, and should be fixed when possible.

Throws:
IOException

getInstance

public static UnitDefinitionMap getInstance()
Obtain an instance of the unit-definition map.


lookup

public UnitDefinition lookup(String k)
Looks up the unit which corresponds to a unit abbreviation


keySet

public Set<String> keySet()
Obtains all of the unit abbreviations known to this map.