|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.pcauto.util.Quantity com.pcauto.util.Density
Density
objects used to hold density information.
Objects can only be instantiated using the DensityFormat
class.
A Density
object's concept of unit is hidden from class
users, and instead inferred from the formatter class at instantiation.
The baseUnit is used to store the unit with which Density
objects will be printed using the overrided toString() method.
A set of arithmetic operations have been included to compare, add, subtract,
divide and multiply currency objects. Arithmetic operations have been
designed to be null
safe.
Field Summary | |
protected static DensityUnits |
baseUnit
|
static Density |
ZERO
Instance of Currency with zero value. |
Fields inherited from class com.pcauto.util.Quantity |
quantity, unit |
Constructor Summary | |
protected |
Density()
Castor needs this, unfortunately |
protected |
Density(double quantity,
DensityUnits unit)
Creates new Density with an initial
double value and int unit. |
Method Summary | |
Density |
add(Density quant)
Adds this Density to the supplied
Density . |
static Density |
add(Density a,
Density b)
Adds supplied Density to other supplied
Density . |
static boolean |
areEqual(Density quant1,
Density quant2)
Determines if two Density objects passed
to the fuction are equal. |
java.lang.Object |
clone()
Creates new Density identical to this
Density |
int |
compareTo(Density quant)
Compares this Density with the specified
Density . |
Density |
divide(java.math.BigDecimal divisor)
Divides this Density by supplied
BigDecimal . |
java.math.BigDecimal |
divide(Density quant)
Divides this Density by supplied
Density . |
boolean |
equals(Density quant)
Compares this Density to the specified
Density . |
static DensityUnits |
getBaseUnit()
Gets base unit with which this density is printed. |
boolean |
greaterThan(Density quant)
Compares this Density to the specified
Density . |
boolean |
lessThan(Density quant)
Compares this Density to the specified
Density . |
Density |
multiply(java.math.BigDecimal multiplier)
Multiplies this Density by supplied
BigDecimal . |
static void |
setBaseUnit(DensityUnits unit)
Sets the "toString" representation of any Density objects
to be of type unit . |
Density |
subtract(Density quant)
Subtracts supplied Density from
this Density . |
Methods inherited from class com.pcauto.util.Quantity |
add, add, areEqual, compareTo, compareTo, divide, equals, equals, getQuantity, getUnit, greaterThan, lessThan, myDivide, myMultiply, setQuantity, setUnit, setZERO, subtract |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static DensityUnits baseUnit
public static final Density ZERO
Currency
with zero value.
Constructor Detail |
protected Density()
protected Density(double quantity, DensityUnits unit)
Density
with an initial
double
value and int
unit.
quantity
- double
densityunit
- DensityUnits
Method Detail |
public static DensityUnits getBaseUnit()
this
density is printed.
DensityUnits
unit with which densities are stored.public static void setBaseUnit(DensityUnits unit)
Density
objects
to be of type unit
.
public java.lang.Object clone()
Density
identical to this
Density
clone
in class Quantity
Density
objectpublic boolean equals(Density quant)
this
Density
to the specified
Density
.
The result is true
if and only if the argument is not
null
and is a Density
object that
has the same value. Null
parameter returns false.
quant
- Density
with which to compare
true
if Densitys are equivalent;
false
othewise.public int compareTo(Density quant)
this
Density
with the specified
Density
. Null
parameter returns 1.
quant
- Density
object with which to compare.
this
Density
is larger.
-1 if this
Density
is smaller.public boolean greaterThan(Density quant)
this
Density
to the specified
Density
.
quant
- Density
object with which to compare.
true
if this
is greater
than quant
;
false
otherwisepublic boolean lessThan(Density quant)
this
Density
to the specified
Density
.
quant
- Density
object with which to compare.
true
if this
is less
than quant
; false
otherwisepublic static boolean areEqual(Density quant1, Density quant2)
Density
objects passed
to the fuction are equal. Two null
are considered equal.
public Density add(Density quant)
this
Density
to the supplied
Density
.
Null
parameter is considered equal to
Density
with ZERO quantity.
quant
- Density
object to add
Density
object resulting from addition operationpublic static Density add(Density a, Density b)
Density
to other supplied
Density
. Null
parameter(s) is
considered to be equal to ZERO quantity.
a
- first Density
objectb
- second Density
object
Density
object resulting from addition of a
and b in Density
a's unitpublic Density subtract(Density quant)
Density
from
this
Density
.
Null
parameter is considered equal to
Density
with zero quantity
quant
- Density
object to subtract
Density
object resulting from subtraction
operation in this
unitpublic java.math.BigDecimal divide(Density quant)
this
Density
by supplied
Density
.
quant
- Density
object to divide by
BigDecimal
object resulting from division operation
ArithmeticException
- on the attempt
to divide by null
or zeropublic Density multiply(java.math.BigDecimal multiplier)
this
Density
by supplied
BigDecimal
.
Density
object resulting
from multiplication operation
ArithmeticException
- on the attempt
to multiply by null
public Density divide(java.math.BigDecimal divisor)
this
Density
by supplied
BigDecimal
.
Density
object resulting from division operation
ArithmeticException
- on the attempt
to divide by null
or zero
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |