This class provides a set of mappings between units and symbols (both ways), between prefixes and symbols
(both ways), and from unit converters to MetricPrefix (one way). No attempt is made to verify the
uniqueness of the mappings.
Mappings are read from a ResourceBundle, the keys of which should consist of a fully-qualified class name, followed by a dot ('.'),
and then the name of a static field belonging to that class, followed optionally by another dot and a number. If the trailing dot and number are
not present, the value associated with the key is treated as a label, otherwise if the trailing dot
and number are present, the value is treated as an alias. Aliases map from String to Unit only,
whereas labels map in both directions. A given unit may have any number of aliases, but may have only one label.
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private static final java. | |
| private final Map | |
| private final Map | |
| private final Map | |
| private final Map |
| Access | Constructor and Description |
|---|---|
| private | |
| private | SymbolMap(ResourceBundle
the resource bundle. rb)Creates a symbol map from the specified resource bundle, |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public Prefix | |
| public Prefix | Returns: the corresponding prefix ornull if none.the unit converter. converter)Returns the prefix for the specified converter. |
| public String | |
| public String | |
| public Unit | |
| public void | |
| public void | |
| public static SymbolMap | |
| public String |
| converterToPrefix | back to summary |
|---|---|
| private final Map<UnitConverter, Prefix> converterToPrefix | |
| logger | back to summary |
|---|---|
| private static final java. | |
| prefixToSymbol | back to summary |
|---|---|
| private final Map<Object, String> prefixToSymbol | |
| symbolToPrefix | back to summary |
|---|---|
| private final Map<String, Object> symbolToPrefix | |
| symbolToUnit | back to summary |
|---|---|
| private final Map<String, Unit<?>> symbolToUnit | |
| unitToSymbol | back to summary |
|---|---|
| private final Map<Unit<?>, String> unitToSymbol | |
| SymbolMap | back to summary |
|---|---|
| private SymbolMap() Creates an empty mapping. | |
| SymbolMap | back to summary |
|---|---|
| private SymbolMap(ResourceBundle rb) Creates a symbol map from the specified resource bundle,
| |
| alias | back to summary |
|---|---|
| public void alias(Unit<?> unit, String symbol) Attaches an alias to the specified unit. Multiple aliases may be attached to the same unit. Aliases are used during parsing to recognize
different variants of the same unit. | |
| getPrefix | back to summary |
|---|---|
| public Prefix getPrefix(String symbol) Returns the prefix (if any) for the specified symbol. | |
| getPrefix | back to summary |
|---|---|
| public Prefix getPrefix(UnitConverter converter) Returns the prefix for the specified converter.
| |
| getSymbol | back to summary |
|---|---|
| public String getSymbol(Unit<?> unit) Returns the symbol (label) for the specified unit. | |
| getSymbol | back to summary |
|---|---|
| public String getSymbol(Prefix prefix) Returns the symbol for the specified prefix. | |
| getUnit | back to summary |
|---|---|
| public Unit Returns the unit for the specified symbol. | |
| label | back to summary |
|---|---|
| public void label(Unit<?> unit, String symbol) Attaches a label to the specified unit. For example: | |
| label | back to summary |
|---|---|
| public void label(Prefix prefix, String symbol) Attaches a label to the specified prefix. For example: | |
| of | back to summary |
|---|---|
| public static SymbolMap of(ResourceBundle rb) Creates a symbol map from the specified resource bundle,
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |