|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.math.DefaultUnit
com.antelmann.math.BaseUnit
public class BaseUnit
base class for providing unit implementations that facilitate conversions based on a standard unit
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.antelmann.util.Localizable |
|---|
Localizable.Adapter |
| Field Summary | |
|---|---|
static UnitConverter |
CONVERTER
supports BaseUnits provided they have the same base unit. |
| Fields inherited from class com.antelmann.math.DefaultUnit |
|---|
name, symbol |
| Constructor Summary | |
|---|---|
BaseUnit(String symbol,
String name,
Unit base,
Converter<Number,Number> thisToBaseConverter)
constructs a unit that allows conversions to other units based on the same base unit |
|
BaseUnit(String symbol,
String name,
Unit base,
Number factor)
|
|
| Method Summary | |
|---|---|
Measurable |
convert(Measurable m)
uses the converter |
static Number |
convert(Number n,
BaseUnit source,
BaseUnit target)
|
Number |
fromBaseUnit(Number n)
converts the given number from the base unit to this unit |
Unit |
getBase()
|
Measurable |
toBaseUnit(Measurable m)
uses the converter |
Number |
toBaseUnit(Number n)
converts the given number from this unit to the base unit |
| Methods inherited from class com.antelmann.math.DefaultUnit |
|---|
equals, getLocale, getUnitName, getUnitSymbol, hashCode, setLocale, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final UnitConverter CONVERTER
fromBaseUnit(Number),
toBaseUnit(Number)| Constructor Detail |
|---|
public BaseUnit(String symbol,
String name,
Unit base,
Number factor)
factor - the factor you have to multiply with to convert to the base unitBaseUnit(String, String, Unit, Converter)
public BaseUnit(String symbol,
String name,
Unit base,
Converter<Number,Number> thisToBaseConverter)
symbol - the symbol of the unitname - the name of the unitbase - the base unit that is the standard for this kind of unitthisToBaseConverter - a converter that allows to convert numbers to the base unit and back| Method Detail |
|---|
public Unit getBase()
public Number toBaseUnit(Number n)
public Number fromBaseUnit(Number n)
public Measurable convert(Measurable m)
throws IllegalArgumentException
IllegalArgumentException
public Measurable toBaseUnit(Measurable m)
throws IllegalArgumentException
IllegalArgumentException
public static Number convert(Number n,
BaseUnit source,
BaseUnit target)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||