|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.unit.Quantity
public class Quantity
A Quantity is a number together with a unit.
Field Summary | |
---|---|
static net.sourceforge.jmisc.Format |
defaultFormat
|
net.sourceforge.jmisc.Format |
format
|
static int |
NO_CHANGE
Returned by set() if there is no unit change. |
static int |
UNIT_CHANGE
Returned by set() if there was a unit changed. |
static int |
UNITS_INCOMPATIBLE
Returned by set() if there the unit changed, and it is not of the same type. |
Constructor Summary | |
---|---|
Quantity()
|
|
Quantity(java.lang.String s)
Create a quantity based on the given string. |
|
Quantity(java.lang.String s,
Unit def)
Create a quantity with the default units specified. |
Method Summary | |
---|---|
void |
convert(Unit u)
Change units, but not the value. |
void |
convert(UnitSystem s)
Change units, but not the value. |
double |
get()
Return this value in the current units. |
double |
in(Unit u)
Return this value in the specified units. |
void |
set(double x)
Set this value based on the current unit. |
void |
set(double x,
Unit u)
Set this value based on the supplied unit. |
int |
set(java.lang.String s)
Set this value and possibly change units. |
int |
set(java.lang.String s,
boolean sloppy)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static net.sourceforge.jmisc.Format defaultFormat
public net.sourceforge.jmisc.Format format
public static int NO_CHANGE
public static int UNIT_CHANGE
public static int UNITS_INCOMPATIBLE
Constructor Detail |
---|
public Quantity()
public Quantity(java.lang.String s) throws ParseException
ParseException
public Quantity(java.lang.String s, Unit def) throws ParseException, UnitMismatchException
ParseException
UnitMismatchException
Method Detail |
---|
public double get()
public double in(Unit u)
public void convert(Unit u)
public void convert(UnitSystem s)
public void set(double x)
public void set(double x, Unit u)
public int set(java.lang.String s) throws ParseException, UnitMismatchException, java.lang.NumberFormatException
ParseException
UnitMismatchException
java.lang.NumberFormatException
public int set(java.lang.String s, boolean sloppy) throws ParseException, UnitMismatchException, java.lang.NumberFormatException
ParseException
UnitMismatchException
java.lang.NumberFormatException
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 |