|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public static interface Dimension.Model
This interface represents the mapping between base units
and dimensions. Custom models may allow
conversions not possible using the standard model.
For example:
public static void main(String[] args) {
Dimension.Model relativistic = new Dimension.Model() {
RationalConverter metreToSecond = new RationalConverter(BigInteger.ONE, BigInteger.valueOf(299792458)); // 1/c
public Dimension getDimension(BaseUnit unit) {
if (unit.equals(METRE)) return Dimension.TIME;
return Dimension.Model.STANDARD.getDimension(unit);
}
public UnitConverter getTransform(BaseUnit unit) {
if (unit.equals(METRE)) return metreToSecond;
return Dimension.Model.STANDARD.getTransform(unit);
}};
Dimension.setModel(relativistic);
// Converts 1.0 GeV (energy) to kg (mass).
System.out.println(Unit.valueOf("GeV").getConverterTo(KILOGRAM).convert(1.0));
}
> 1.7826617302520883E-27
| Field Summary | |
|---|---|
static Dimension.Model |
STANDARD
Holds the standard model (default). |
| Method Summary | |
|---|---|
Dimension |
getDimension(BaseUnit<?> unit)
Returns the dimension of the specified base unit (a dimension particular to the base unit if the base unit is not recognized). |
UnitConverter |
getTransform(BaseUnit<?> unit)
Returns the normalization transform of the specified base unit ( IDENTITY if the base unit is
not recognized). |
| Field Detail |
|---|
static final Dimension.Model STANDARD
| Method Detail |
|---|
Dimension getDimension(BaseUnit<?> unit)
unit - the base unit for which the dimension is returned.
UnitConverter getTransform(BaseUnit<?> unit)
IDENTITY if the base unit is
not recognized).
unit - the base unit for which the transform is returned.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||