|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.measure.unit.format.SymbolMap
public class SymbolMap
The SymbolMap class provides a set of mappings between
Units and symbols (both ways),
between Prefixes and symbols
(both ways), and from UnitConverters to Prefixes (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.
| Constructor Summary | |
|---|---|
SymbolMap()
Creates an empty mapping. |
|
SymbolMap(java.util.ResourceBundle rb)
Creates a symbol map from the specified resource bundle, |
|
| Method Summary | |
|---|---|
void |
alias(Unit<?> unit,
java.lang.String symbol)
Attaches an alias to the specified unit. |
javax.measure.unit.format.Prefix |
getPrefix(java.lang.String symbol)
Returns the prefix (if any) for the specified symbol. |
javax.measure.unit.format.Prefix |
getPrefix(UnitConverter converter)
Returns the prefix for the specified converter. |
java.lang.String |
getSymbol(javax.measure.unit.format.Prefix prefix)
Returns the symbol for the specified prefix. |
java.lang.String |
getSymbol(Unit<?> unit)
Returns the symbol (label) for the specified unit. |
Unit<?> |
getUnit(java.lang.String symbol)
Returns the unit for the specified symbol. |
void |
label(javax.measure.unit.format.Prefix prefix,
java.lang.String symbol)
Attaches a label to the specified prefix. |
void |
label(Unit<?> unit,
java.lang.String symbol)
Attaches a label to the specified unit. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SymbolMap()
public SymbolMap(java.util.ResourceBundle rb)
rb - the resource bundle.| Method Detail |
|---|
public void label(Unit<?> unit,
java.lang.String symbol)
symbolMap.label(DAY.multiply(365), "year");
symbolMap.label(NonSI.FOOT, "ft");
unit - the unit to label.symbol - the new symbol for the unit.
public void alias(Unit<?> unit,
java.lang.String symbol)
symbolMap.alias(NonSI.FOOT, "foot");
symbolMap.alias(NonSI.FOOT, "feet");
symbolMap.alias(SI.METER, "meter");
symbolMap.alias(SI.METER, "metre");
unit - the unit to label.symbol - the new symbol for the unit.
public void label(javax.measure.unit.format.Prefix prefix,
java.lang.String symbol)
symbolMap.label(Prefix.GIGA, "G");
symbolMap.label(Prefix.MICRO, "ยต");
public Unit<?> getUnit(java.lang.String symbol)
symbol - the symbol.
null if none.public java.lang.String getSymbol(Unit<?> unit)
unit - the corresponding symbol.
null if none.public javax.measure.unit.format.Prefix getPrefix(java.lang.String symbol)
symbol - the unit symbol.
null if none.public javax.measure.unit.format.Prefix getPrefix(UnitConverter converter)
converter - the unit converter.
null if none.public java.lang.String getSymbol(javax.measure.unit.format.Prefix prefix)
prefix - the prefix.
null if none.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||