|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcds.astro.Converter
public class Converter
This class, tightly connected to the Unit class,
gathers non-standard unit conversions.
Standard conversions are made between units having the same physical dimension, as e.g. a conversion between Hz and km/s/Mpc. Conversion bewteen units having different physical dimensions are called non-standard, e.g. between hours (time) and degrees (angle). This default class contains linear transformations only; a derived class can be used if necessary to generate more complex converters.
| Field Summary | |
|---|---|
double |
factor
The conversion factor, if used (target = factor * source) |
Unit |
source
The source unit |
Unit |
target
The target unit |
| Constructor Summary | |
|---|---|
Converter(java.lang.String source_unit,
java.lang.String target_unit)
Creation of a standard converter. |
|
Converter(java.lang.String source_unit,
java.lang.String target_unit,
double factor)
Creation (and registration) of a unit converter. |
|
| Method Summary | |
|---|---|
double |
convert(double value)
Convert a number. |
double |
convert(java.lang.String value)
Convert a value. |
void |
dump(java.lang.String title)
Dump the object |
java.lang.String |
toString()
Standard edition of the unit converter |
java.lang.String |
transform(double value)
Convert a value, return its edited form. |
java.lang.String |
transform(java.lang.String value)
Convert a value, return its edited form. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public Unit source
public Unit target
public double factor
| Constructor Detail |
|---|
public Converter(java.lang.String source_unit,
java.lang.String target_unit)
Unit.convert(cds.astro.Unit, cds.astro.Unit))
source_unit - unit of source valuetarget_unit - unit of target value
public Converter(java.lang.String source_unit,
java.lang.String target_unit,
double factor)
Unit.convert(cds.astro.Unit, cds.astro.Unit),
i.e. the convert(double) method defined here is applied.Examples could be Converter("h", "deg", 15.) or Converter("\"d:m:s\"", "\"h:m:s\"", 1./15.)
source_unit - unit of source value.target_unit - unit of target valuefactor - factor of conversion in: target = factor * source| Method Detail |
|---|
public void dump(java.lang.String title)
title - title line of the dump
public double convert(double value)
throws java.lang.ArithmeticException
value - the value (expressed in source)
java.lang.ArithmeticException
public double convert(java.lang.String value)
throws java.text.ParseException,
java.lang.ArithmeticException
value - the value (expressed in source)
java.text.ParseException
java.lang.ArithmeticException
public java.lang.String transform(java.lang.String value)
throws java.text.ParseException,
java.lang.ArithmeticException
value - the value (expressed in source)
java.text.ParseException
java.lang.ArithmeticException
public java.lang.String transform(double value)
throws java.lang.ArithmeticException
value - the value (expressed in source)
java.lang.ArithmeticExceptionpublic java.lang.String toString()
toString in class java.lang.Object
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||