org.vizzini.math
Class UnitConverter

java.lang.Object
  extended by org.vizzini.math.UnitConverter

public class UnitConverter
extends Object

Provides convenience methods related to unit conversion.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson

Field Summary
static String AU
          Astronomical units constant.
static String DAYS
          Days constant.
static String DEGREES
          Degrees constant.
static String FT
          Feet constant.
static String HOURS
          Hours constant.
static String KG
          Kilogram constant.
static String KM
          Kilometers constant.
static String M
          Meters constant.
static String MIN
          Minutes constant.
static String MW
          Mega-Watts constant.
static String RADIANS
          Radians constant.
static String SEC
          Seconds constant.
static String YEARS
          Years constant.
 
Method Summary
 double convert(double value, String fromUnits, String toUnits)
          Convert the given value to the new units.
 double convertString(String valueAndUnitsStr, String toUnits)
          Return the value given by the string in the desired units.
static UnitConverter getInstance()
          Return the singleton instance of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEGREES

public static final String DEGREES
Degrees constant.

See Also:
Constant Field Values

RADIANS

public static final String RADIANS
Radians constant.

See Also:
Constant Field Values

AU

public static final String AU
Astronomical units constant.

See Also:
Constant Field Values

FT

public static final String FT
Feet constant.

See Also:
Constant Field Values

M

public static final String M
Meters constant.

See Also:
Constant Field Values

KM

public static final String KM
Kilometers constant.

See Also:
Constant Field Values

YEARS

public static final String YEARS
Years constant.

See Also:
Constant Field Values

DAYS

public static final String DAYS
Days constant.

See Also:
Constant Field Values

HOURS

public static final String HOURS
Hours constant.

See Also:
Constant Field Values

MIN

public static final String MIN
Minutes constant.

See Also:
Constant Field Values

SEC

public static final String SEC
Seconds constant.

See Also:
Constant Field Values

MW

public static final String MW
Mega-Watts constant.

See Also:
Constant Field Values

KG

public static final String KG
Kilogram constant.

See Also:
Constant Field Values
Method Detail

getInstance

public static UnitConverter getInstance()
Return the singleton instance of this class.

Returns:
The singleton instance.
Since:
v0.3

convert

public double convert(double value,
                      String fromUnits,
                      String toUnits)
Convert the given value to the new units.

Parameters:
value - Value to convert.
fromUnits - Current value units.
toUnits - Desired units.
Returns:
value converted to the desired units.
Since:
v0.3

convertString

public double convertString(String valueAndUnitsStr,
                            String toUnits)
Return the value given by the string in the desired units.

Parameters:
valueAndUnitsStr - String which provides the value, and optionally the units (separated by a space). For example, "1.99e30 kg".
toUnits - Desired units.
Since:
v0.3


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02