|
deegree 2.5 (2011/06/29 09:44 build-8-official) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.deegree.crs.Identifiable org.deegree.crs.components.Unit
public final class Unit
The Unit
class defines a mechanism to convert between different measurements units, such as british_yard
and meter.
Field Summary | |
---|---|
static Unit |
ARC_SEC
Unit of angle, which is defined to be 1/3600 of a degree, or PI/(180*3600) Radian. |
static Unit |
BRITISHYARD
British yard; unit of length. |
static Unit |
DAY
Unit of time. |
static Unit |
DEGREE
Unit of angle. |
static Unit |
METRE
Base unit of length. |
static Unit |
MILLISECOND
Unit of time. |
static Unit |
RADIAN
Unit of angle. |
static Unit |
SECOND
Base unit of time. |
static Unit |
USFOOT
US foot; unit of length, with base unit of 0.304 meter. |
Constructor Summary | |
---|---|
Unit(java.lang.String symbol,
java.lang.String name)
Unit constructor. |
|
Unit(java.lang.String symbol,
java.lang.String name,
double scale,
Unit baseType)
Unit constructor, which uses the name as the id. |
|
Unit(java.lang.String symbol,
java.lang.String name,
java.lang.String id)
Unit constructor. |
|
Unit(java.lang.String symbol,
java.lang.String name,
java.lang.String id,
double scale,
Unit baseType)
Unit constructor. |
Method Summary | |
---|---|
boolean |
canConvert(Unit other)
Check if amount of the specified unit can be converted into amount of this unit. |
double |
convert(double value,
Unit targetUnit)
Convert a value in this unit to the given unit if possible. |
static Unit |
createUnitFromString(java.lang.String unit)
Will create a unit from the given String. |
boolean |
equals(java.lang.Object object)
Compare this unit symbol with the specified object for equality. |
double |
getScale()
|
java.lang.String |
getSymbol()
|
int |
hashCode()
Implementation as proposed by Joshua Block in Effective Java (Addison-Wesley 2001), which supplies an even distribution and is relatively fast. |
boolean |
isBaseType()
|
double |
toBaseUnits(double value)
Convert a value in this unit to the base unit, e.g. degree->radians |
java.lang.String |
toString()
|
Methods inherited from class org.deegree.crs.Identifiable |
---|
checkForNullObject, checkForNullObject, checkForNullObject, getAreaOfUse, getAreaOfUseBBox, getAreasOfUse, getDescription, getDescriptions, getIdAndName, getIdentifier, getIdentifiers, getName, getNames, getVersion, getVersions, hasID |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Unit RADIAN
public static final Unit DEGREE
public static final Unit ARC_SEC
public static final Unit METRE
public static final Unit BRITISHYARD
public static final Unit USFOOT
public static final Unit SECOND
public static final Unit MILLISECOND
public static final Unit DAY
Constructor Detail |
---|
public Unit(java.lang.String symbol, java.lang.String name, java.lang.String id)
symbol
- name
- of the unit, e.g. metreid
- of the unitpublic Unit(java.lang.String symbol, java.lang.String name)
symbol
- name
- of the unit, e.g. metrepublic Unit(java.lang.String symbol, java.lang.String name, double scale, Unit baseType)
symbol
- of the units, e.g. 'm'name
- human readable name, e.g. metrescale
- to convert to the base type.baseType
- the baseTypepublic Unit(java.lang.String symbol, java.lang.String name, java.lang.String id, double scale, Unit baseType)
symbol
- of the units, e.g. 'm'name
- human readable name, e.g. metreid
- of the unit.scale
- to convert to the base type.baseType
- the baseTypeMethod Detail |
---|
public static Unit createUnitFromString(java.lang.String unit)
null will be returned.
- Parameters:
unit
- to convert to an actual unit.
- Returns:
- a unit or
null
public boolean canConvert(Unit other)
other
-
public final double convert(double value, Unit targetUnit)
value
- to be convertedtargetUnit
- to convert to
java.lang.IllegalArgumentException
- if no conversion can be applied.public final double toBaseUnits(double value)
value
- to be converted
public java.lang.String toString()
toString
in class Identifiable
public boolean equals(java.lang.Object object)
equals
in class Identifiable
public int hashCode()
Combining the hash code(s) computed above: result = 37 * result + code;
hashCode
in class java.lang.Object
Object.hashCode()
public final double getScale()
public final boolean isBaseType()
public java.lang.String getSymbol()
|
deegree 2.5 (2011/06/29 09:44 build-8-official) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org