com.javadocmd.simplelatlng.util
Enum LengthUnit

java.lang.Object
  extended by java.lang.Enum<LengthUnit>
      extended by com.javadocmd.simplelatlng.util.LengthUnit
All Implemented Interfaces:
Serializable, Comparable<LengthUnit>

public enum LengthUnit
extends Enum<LengthUnit>

A utility class for handling units and unit conversions within this library.

Author:
Tyler Coles

Enum Constant Summary
KILOMETER
          Kilometers, the primary unit.
METER
          Meters, for ease of use.
MILE
          Miles, using the scale factor 0.6213712 miles per kilometer.
NAUTICAL_MILE
          Nautical miles, using the scale factor 0.5399568 nautical miles per kilometer.
ROD
          Rods, using the scale factor 0.0050292 rods to the kilometer.
 
Field Summary
static LengthUnit PRIMARY
          The primary length unit.
 
Method Summary
 double convertTo(LengthUnit toUnit, double value)
          Convert a value of this unit type to the units specified in the parameters.
 double getScaleFactor()
          Retrieve the scale factor between this unit and the primary length unit.
static LengthUnit valueOf(String name)
          Returns the enum constant of this type with the specified name.
static LengthUnit[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

MILE

public static final LengthUnit MILE
Miles, using the scale factor 0.6213712 miles per kilometer.


NAUTICAL_MILE

public static final LengthUnit NAUTICAL_MILE
Nautical miles, using the scale factor 0.5399568 nautical miles per kilometer.


ROD

public static final LengthUnit ROD
Rods, using the scale factor 0.0050292 rods to the kilometer. Because your car gets forty rods to the hogshead and that's they way you likes it.


KILOMETER

public static final LengthUnit KILOMETER
Kilometers, the primary unit.


METER

public static final LengthUnit METER
Meters, for ease of use.

Field Detail

PRIMARY

public static final LengthUnit PRIMARY
The primary length unit. All scale factors are relative to this unit. Any conversion not involving the primary unit will first be converted to this unit, then to the desired unit.

Method Detail

values

public static LengthUnit[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (LengthUnit c : LengthUnit.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static LengthUnit valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

convertTo

public double convertTo(LengthUnit toUnit,
                        double value)
Convert a value of this unit type to the units specified in the parameters.

Parameters:
toUnit - the unit to convert to.
value - the value to convert.
Returns:
the converted value.

getScaleFactor

public double getScaleFactor()
Retrieve the scale factor between this unit and the primary length unit.

Returns:
the scale factor.


Copyright © 2010-2013. All Rights Reserved.