public class Quantity extends Object implements Comparable
Constructor and Description |
---|
Quantity(Double inValue,
String inUnit)
Convenience constructor that will call Unit.valueOf() on the specified unit string.
|
Quantity(Double inValue,
Unit inUnit) |
Quantity(Float inValue,
String inUnit)
Convenience constructor that will call Unit.valueOf() on the specified unit string.
|
Quantity(Float inValue,
Unit inUnit) |
Quantity(Integer inValue,
String inUnit)
Convenience constructor that will call Unit.valueOf() on the specified unit string.
|
Quantity(Integer inValue,
Unit inUnit) |
Quantity(Long inValue,
String inUnit)
Convenience constructor that will call Unit.valueOf() on the specified unit string.
|
Quantity(Long inValue,
Unit inUnit) |
Quantity(String inValue)
Convenience constructor.
|
Modifier and Type | Method and Description |
---|---|
Quantity |
add(Quantity inValue) |
Quantity |
autoScale() |
Quantity |
autoScale(SI_ScalingFactor[] inScalingValues) |
int |
compareTo(Object inObj2) |
Quantity |
convertTo(Unit inUnit) |
Quantity |
divideBy(double inValue) |
Double |
doubleValue() |
boolean |
equals(Object inObj2) |
Float |
floatValue() |
Unit |
getUnit() |
boolean |
greaterThan(Quantity inValue) |
boolean |
greaterThanOrEqualTo(Quantity inValue) |
int |
hashCode() |
Integer |
intValue() |
Quantity |
invert() |
boolean |
lessThan(Quantity inValue) |
boolean |
lessThanOrEqualTo(Quantity inValue) |
Long |
longValue() |
Quantity |
multiplyBy(double inValue) |
void |
scale(QuantityType inQuantityType,
SI_ScalingFactor inScalingFactor) |
Quantity |
subtract(Quantity inValue) |
String |
toString() |
String |
toString(DecimalFormat inFormat)
Outputs the Quantity as a numeric value followed by the units where the
numeric portion is formatted according to the specified DecimalFormat object.
|
String |
toString(String inFmtString)
Outputs the Quantity as a numeric value followed by the units where the
numeric portion is formatted according to the specified sprintf string.
|
void |
verifyQuantityType(QuantityType inExpectedQuantityType)
Performs a validation test to ensure that the unit is of the expected quantity type.
|
public Quantity(Double inValue, String inUnit)
inValue
- the numeric amount as a doubleinUnit
- the volume unit of the specified amountpublic Quantity(Float inValue, String inUnit)
inValue
- the numeric amount as a floatinUnit
- the volume unit of the specified amountpublic Quantity(Integer inValue, String inUnit)
inValue
- the numeric amount as an integerinUnit
- the volume unit of the specified amountpublic Quantity(Long inValue, String inUnit)
inValue
- the numeric amount as an integerinUnit
- the volume unit of the specified amountpublic Quantity(String inValue)
inValue
- the string valuepublic String toString(String inFmtString)
inFmtString
- a sprintf format specificationpublic String toString(DecimalFormat inFormat)
inFormat
- a DecimalFormat format specificationpublic int compareTo(Object inObj2)
compareTo
in interface Comparable
public void scale(QuantityType inQuantityType, SI_ScalingFactor inScalingFactor)
public Quantity multiplyBy(double inValue)
public boolean lessThanOrEqualTo(Quantity inValue)
public boolean greaterThan(Quantity inValue)
public boolean greaterThanOrEqualTo(Quantity inValue)
public Double doubleValue()
public Float floatValue()
public Quantity autoScale(SI_ScalingFactor[] inScalingValues)
public void verifyQuantityType(QuantityType inExpectedQuantityType)
inExpectedQuantityType
- the quantity type that is expected.InvalidValueException
- if the unit isn't set or is not of the expected type.
jataylor@hairyfatguy.com