Package uk.me.nxg.unity

# Class UnitDefinitionMap

java.lang.Object
uk.me.nxg.unity.UnitDefinitionMap

public abstract class UnitDefinitionMap extends 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 Summary

Constructors
Modifier
Constructor
Description
`protected`
`UnitDefinitionMap()`
Constructs a new unit-definition map.

## Method Summary

Modifier and Type
Method
Description
`static UnitDefinitionMap`
`getInstance()`
Obtain an instance of the unit-definition map.
`abstract UnitDefinition`
`lookupUnitDefinition(String uri)`
Obtain information about a unit, keyed by the unit's URI, represented as a string.
`UnitDefinition`
`lookupUnitDefinition(Syntax syntax, String symbol)`
Obtain unit-definition information for a symbol, as interpreted in a particular syntax.
`UnitRepresentation`
`lookupUnitRepresentation(Syntax syntax, UnitDefinition ud)`
Obtain information about how a unit is represented in a particular syntax.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### UnitDefinitionMap

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

## Method Details

### getInstance

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

Returns:
  the singleton UnitDefinitionMap

### lookupUnitDefinition

public UnitDefinition lookupUnitDefinition(Syntax syntax, 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:
  `syntax` - one of the syntaxes of `Syntax`
  `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.
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(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