Class UnitDefinitionMap


  • public abstract class UnitDefinitionMap
    extends java.lang.Object
    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().

    • Constructor Detail

      • UnitDefinitionMap

        protected UnitDefinitionMap()
        Constructs a new unit-definition map. This is protected on purpose – instances should be retrieved using the getInstance() method.
    • Method Detail

      • getInstance

        public static UnitDefinitionMap getInstance()
        Obtain an instance of the unit-definition map.
        Returns:
        the singleton UnitDefinitionMap
      • lookupUnitDefinition

        public UnitDefinition lookupUnitDefinition​(Syntax syntax,
                                                   java.lang.String symbol)
        Obtain unit-definition information for a symbol, as interpreted in a particular syntax. Return null if the syntax is unrecognised, or if the symbol is not recognised within that syntax
        Parameters:
        symbol - a symbol for a unit, without prefix (eg 'm' for metre, not 'mm') If the syntax is passed as Syntax.ALL, then look up the definition in all of the available readable syntaxes. This may be of use when dealing with a ‘guessed’ unit.
        syntax - one of the syntaxes of Syntax
        Returns:
        a UnitDefinition instance, or null if this is not available
      • lookupUnitRepresentation

        public UnitRepresentation lookupUnitRepresentation​(Syntax syntax,
                                                           UnitDefinition ud)
        Obtain information about how a unit is represented in a particular syntax. Return null if the syntax is unrecognised, or if the unit has no representation within the given syntax. If the syntax is passed as Syntax.ALL, then look up the definition in all of the available readable syntaxes. This may be of use when dealing with a ‘guessed’ unit.
        Parameters:
        syntax - one of the known syntaxes
        ud - a UnitDefinition instance
        Returns:
        representation information, or null if this is not available
      • lookupUnitDefinition

        public abstract UnitDefinition lookupUnitDefinition​(java.lang.String uri)
        Obtain information about a unit, keyed by the unit's URI, represented as a string.
        Parameters:
        uri - the string representation of a unit' URI
        Returns:
        a UnitDefinition instance, or null if this is not available