javax.units
Class Unit

java.lang.Object
  extended byjavax.units.Unit
All Implemented Interfaces:
java.io.Serializable

public final class Unit
extends java.lang.Object
implements java.io.Serializable

Placeholder for future Unit class. This skeleton will be removed when the real classes (from JSR-108: Units specification) will be publicly available.

IMPORTANT: future version will NOT be compatible will this one. Remind, this is a temporary class!

See Also:
Serialized Form

Field Summary
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.
private static java.util.Map pool
          Pool of units.
private  double scale
          The scale factor.
static Unit SECOND
          Base unit of time.
private  java.lang.String symbol
          The unit's symbol.
private  Unit unit
          Base unit, or this if none.
 
Constructor Summary
private Unit(java.lang.String symbol)
          Unit constructor.
private Unit(java.lang.String symbol, double scale, Unit unit)
          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 unit)
          Convert a value from one unit to an other.
 boolean equals(java.lang.Object object)
          Compare this unit symbol with the specified object for equality.
static Unit get(java.lang.String symbol)
          Returns an unit instance.
 int hashCode()
          Returns a hash code value.
 java.lang.String toString()
          Returns a string representation of this unit's symbol.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

pool

private static final java.util.Map pool
Pool of units.


DEGREE

public static final Unit DEGREE
Unit of angle.


METRE

public static final Unit METRE
Base unit of length.


BRITISHYARD

public static final Unit BRITISHYARD
British yard; unit of length.


SECOND

public static final Unit SECOND
Base unit of time.


MILLISECOND

public static final Unit MILLISECOND
Unit of time.


DAY

public static final Unit DAY
Unit of time.


symbol

private final java.lang.String symbol
The unit's symbol.


scale

private final double scale
The scale factor.


unit

private final Unit unit
Base unit, or this if none.

Constructor Detail

Unit

private Unit(java.lang.String symbol)
Unit constructor. Don't allow user creation, since this is not the official Unit class.


Unit

private Unit(java.lang.String symbol,
             double scale,
             Unit unit)
Unit constructor. Don't allow user creation, since this is not the official Unit class.

Method Detail

get

public static Unit get(java.lang.String symbol)
Returns an unit instance.


canConvert

public boolean canConvert(Unit other)
Check if amount of the specified unit can be converted into amount of this unit.


convert

public double convert(double value,
                      Unit unit)
Convert a value from one unit to an other. This method is not implemented (the JSR-108 will provide the reference implementation).


toString

public java.lang.String toString()
Returns a string representation of this unit's symbol.


hashCode

public int hashCode()
Returns a hash code value.


equals

public boolean equals(java.lang.Object object)
Compare this unit symbol with the specified object for equality. Only symbols are compared; other parameters are ignored.