org.elasticsearch.common.unit
Enum DistanceUnit

java.lang.Object
  extended by java.lang.Enum<DistanceUnit>
      extended by org.elasticsearch.common.unit.DistanceUnit
All Implemented Interfaces:
Serializable, Comparable<DistanceUnit>

public enum DistanceUnit
extends Enum<DistanceUnit>


Enum Constant Summary
KILOMETERS
           
MILES
           
 
Field Summary
protected  double distancePerDegree
           
protected  double earthCircumference
           
protected  double earthRadius
           
 
Method Summary
static double convert(double distance, DistanceUnit from, DistanceUnit to)
          Converts the given distance from the given DistanceUnit, to the given DistanceUnit
static DistanceUnit fromString(String unit)
           
 double getDistancePerDegree()
           
 double getEarthCircumference()
           
 double getEarthRadius()
           
static double parse(String distance, DistanceUnit defaultUnit, DistanceUnit to)
           
static DistanceUnit parseUnit(String distance, DistanceUnit defaultUnit)
           
static DistanceUnit readDistanceUnit(StreamInput in)
           
abstract  double toKilometers(double distance)
           
abstract  double toMiles(double distance)
           
abstract  String toString(double distance)
           
static DistanceUnit valueOf(String name)
          Returns the enum constant of this type with the specified name.
static DistanceUnit[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
static void writeDistanceUnit(StreamOutput out, DistanceUnit unit)
           
 
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

MILES

public static final DistanceUnit MILES

KILOMETERS

public static final DistanceUnit KILOMETERS
Field Detail

earthCircumference

protected final double earthCircumference

earthRadius

protected final double earthRadius

distancePerDegree

protected final double distancePerDegree
Method Detail

values

public static DistanceUnit[] 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 (DistanceUnit c : DistanceUnit.values())
    System.out.println(c);

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

valueOf

public static DistanceUnit 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

convert

public static double convert(double distance,
                             DistanceUnit from,
                             DistanceUnit to)
Converts the given distance from the given DistanceUnit, to the given DistanceUnit

Parameters:
distance - Distance to convert
from - Unit to convert the distance from
to - Unit of distance to convert to
Returns:
Given distance converted to the distance in the given uni

parse

public static double parse(String distance,
                           DistanceUnit defaultUnit,
                           DistanceUnit to)

parseUnit

public static DistanceUnit parseUnit(String distance,
                                     DistanceUnit defaultUnit)

getEarthCircumference

public double getEarthCircumference()

getEarthRadius

public double getEarthRadius()

getDistancePerDegree

public double getDistancePerDegree()

toMiles

public abstract double toMiles(double distance)

toKilometers

public abstract double toKilometers(double distance)

toString

public abstract String toString(double distance)

fromString

public static DistanceUnit fromString(String unit)

writeDistanceUnit

public static void writeDistanceUnit(StreamOutput out,
                                     DistanceUnit unit)
                              throws IOException
Throws:
IOException

readDistanceUnit

public static DistanceUnit readDistanceUnit(StreamInput in)
                                     throws IOException
Throws:
IOException


Copyright © 2009-2012. All Rights Reserved.