|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.unit.UnitSystem
public class UnitSystem
A UnitSystem is a collection of prefered units, such as metric or English. For example, if want to convert from Metric units to inches, you can use the following code:
English e = new English(); e.add("in"); System.out.println("length: "+ e.pick( Unit.makeUnit("m"))); // prints "in" System.out.println("area: "+e.pick( Unit.makeUnit("m^2")));// prints "in^2" System.out.println("area: "+e.pick( Unit.makeUnit("acre")));// prints "in^2" System.out.println("force: "+ e.pick( Unit.makeUnit("N"))); // prints "lb" System.out.println("mass: "+ e.pick( Unit.makeUnit("kg"))); // prints "lbm"
Constructor Summary | |
---|---|
UnitSystem()
Create a default system of units -- Metric, without special units like W, N or J. |
|
UnitSystem(java.lang.String[] a)
Create a default system of units -- and add all the units in a to it. |
Method Summary | |
---|---|
void |
add(java.lang.String u)
Add the unit u to this system. |
void |
add(java.lang.String[] u)
Add the unit u to this system. |
void |
add(Unit u)
Add the unit u to this system. |
void |
add(Unit[] u)
Add the unit u to this system. |
boolean |
addPrimitive(Unit u)
This attempts to add a unit as a measurement of one of the seven primitives. |
java.lang.Object |
clone()
|
Unit |
pick(Unit u)
Return the unit in this system that is the same type as u. |
void |
remove(java.lang.String u)
Remove this unit from the list of prefered units. |
void |
remove(Unit u)
Remove this unit from the list of prefered units. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public UnitSystem()
public UnitSystem(java.lang.String[] a) throws ParseException
ParseException
Method Detail |
---|
public java.lang.Object clone()
clone
in class java.lang.Object
public void add(java.lang.String u) throws ParseException
add
for more information.
ParseException
public void add(java.lang.String[] u) throws ParseException
add
for more information.
ParseException
public void add(Unit[] u)
add
for more information.
public void add(Unit u)
public void remove(Unit u)
public void remove(java.lang.String u)
public boolean addPrimitive(Unit u)
public Unit pick(Unit u)
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |