|
|||||||||
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.Dimension
Dimension
objects used to hold dimension information.
Objects can only be instantiated using the DimensionFormat
class.
A Dimension
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 Dimension
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 DimensionUnits |
baseUnit
|
static Dimension |
ZERO
Instance of Currency with zero value. |
Fields inherited from class com.pcauto.util.Quantity |
quantity, unit |
Constructor Summary | |
protected |
Dimension()
Castor needs this, unfortunately |
protected |
Dimension(double quantity,
DimensionUnits unit)
Creates new Dimension with an initial
double value and int unit. |
Method Summary | |
Dimension |
add(Dimension quant)
Adds this Dimension to the supplied
Dimension . |
static Dimension |
add(Dimension a,
Dimension b)
Adds supplied Dimension to other supplied
Dimension . |
static boolean |
areEqual(Dimension quant1,
Dimension quant2)
Determines if two Dimension objects passed
to the fuction are equal. |
java.lang.Object |
clone()
Creates new Dimension identical to this
Dimension |
int |
compareTo(Dimension quant)
Compares this Dimension with the specified
Dimension . |
Dimension |
divide(java.math.BigDecimal divisor)
Divides this Dimension by supplied
BigDecimal . |
java.math.BigDecimal |
divide(Dimension quant)
Divides this Dimension by supplied
Dimension . |
boolean |
equals(Dimension quant)
Compares this Dimension to the specified
Dimension . |
static DimensionUnits |
getBaseUnit()
Gets base unit with which this dimension is printed. |
boolean |
greaterThan(Dimension quant)
Compares this Dimension to the specified
Dimension . |
boolean |
lessThan(Dimension quant)
Compares this Dimension to the specified
Dimension . |
Dimension |
multiply(java.math.BigDecimal multiplier)
Multiplies this Dimension by supplied
BigDecimal . |
static void |
setBaseUnit(DimensionUnits unit)
Sets the "toString" representation of any Dimension objects
to be of type unit . |
Dimension |
subtract(Dimension quant)
Subtracts supplied Dimension from
this Dimension . |
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 DimensionUnits baseUnit
public static final Dimension ZERO
Currency
with zero value.
Constructor Detail |
protected Dimension()
protected Dimension(double quantity, DimensionUnits unit)
Dimension
with an initial
double
value and int
unit.
quantity
- double
dimensionunit
- DimensionUnits
Method Detail |
public static DimensionUnits getBaseUnit()
this
dimension is printed.
DimensionUnits
unit with which dimensions are stored.public static void setBaseUnit(DimensionUnits unit)
Dimension
objects
to be of type unit
.
public java.lang.Object clone()
Dimension
identical to this
Dimension
clone
in class Quantity
Dimension
objectpublic boolean equals(Dimension quant)
this
Dimension
to the specified
Dimension
.
The result is true
if and only if the argument is not
null
and is a Dimension
object that
has the same value. Null
parameter returns false.
quant
- Dimension
with which to compare
true
if Dimensions are equivalent;
false
othewise.public int compareTo(Dimension quant)
this
Dimension
with the specified
Dimension
. Null
parameter returns 1.
quant
- Dimension
object with which to compare.
this
Dimension
is larger.
-1 if this
Dimension
is smaller.public boolean greaterThan(Dimension quant)
this
Dimension
to the specified
Dimension
.
quant
- Dimension
object with which to compare.
true
if this
is greater
than quant
;
false
otherwisepublic boolean lessThan(Dimension quant)
this
Dimension
to the specified
Dimension
.
quant
- Dimension
object with which to compare.
true
if this
is less
than quant
; false
otherwisepublic static boolean areEqual(Dimension quant1, Dimension quant2)
Dimension
objects passed
to the fuction are equal. Two null
are considered equal.
public Dimension add(Dimension quant)
this
Dimension
to the supplied
Dimension
.
Null
parameter is considered equal to
Dimension
with ZERO quantity.
quant
- Dimension
object to add
Dimension
object resulting from addition operationpublic static Dimension add(Dimension a, Dimension b)
Dimension
to other supplied
Dimension
. Null
parameter(s) is
considered to be equal to ZERO quantity.
a
- first Dimension
objectb
- second Dimension
object
Dimension
object resulting from addition of a
and b in Dimension
a's unitpublic Dimension subtract(Dimension quant)
Dimension
from
this
Dimension
.
Null
parameter is considered equal to
Dimension
with zero quantity
quant
- Dimension
object to subtract
Dimension
object resulting from subtraction
operation in this
unitpublic java.math.BigDecimal divide(Dimension quant)
this
Dimension
by supplied
Dimension
.
quant
- Dimension
object to divide by
BigDecimal
object resulting from division operation
ArithmeticException
- on the attempt
to divide by null
or zeropublic Dimension multiply(java.math.BigDecimal multiplier)
this
Dimension
by supplied
BigDecimal
.
Dimension
object resulting
from multiplication operation
ArithmeticException
- on the attempt
to multiply by null
public Dimension divide(java.math.BigDecimal divisor)
this
Dimension
by supplied
BigDecimal
.
Dimension
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 |