|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xspace.mx.physics.immutable.BaseUnit
The class from which all other units in this package are derived. This class provides most of the functionality/implementation for this package.
Internally, the measurements are stored as multiples of base units of the SI system (e.g. meters, seconds, kilograms, etc.)
Field Summary | |
protected static int |
DIM_ANGLE
|
protected static int |
DIM_LENGTH
|
protected static int |
DIM_MASS
|
protected static int |
DIM_TIME
|
protected Unit[] |
dims
|
protected double |
systemValue
The internally stored value of this Measurement |
protected static double |
TOL
The tolerance used when inspecting the power of a Unit . |
Constructor Summary | |
BaseUnit()
Creates a unit-less Measurement equal to one (1) |
|
BaseUnit(double value)
Creates a unit-less Measurement equal to the input value |
Method Summary | |
Measurement |
copy()
Returns a new instance of a Measurement that is "equivalent" in value to this Measurement. |
protected BaseUnit |
copyBaseUnit()
|
Measurement |
div(double scaling)
Divides this Measurement by a scalar value. |
Measurement |
div(Measurement other)
Divides this Measurement by the other Measurement. |
protected Measurement |
divInternal(double scaling)
|
protected Measurement |
divInternal(Measurement other)
|
java.lang.String |
getAbbr()
An abbreviated description of the units of this Measurement |
java.lang.String |
getDescription()
A description of the units of this Measurement |
SystemOfUnits |
getSystem()
The system of units being used by this Measurement. |
Unit[] |
getSystemDimensions()
An array of Unit s within the SystemOfUnits being used by this Measurement. |
double |
getSystemValue()
The internal value of this measurement. |
double |
getValue(Measurement multipleOf)
The value of this measurement relative to the dimensions of the input measurement. |
boolean |
isSameMeasurementType(Measurement other)
Determine whether this measurement and the other measurement are comparable |
Measurement |
minus(Measurement other)
Subtracts the other Measurement to this Measurement. |
protected Measurement |
minusInternal(Measurement other)
|
Measurement |
mult(double scaling)
Multiplies this Measurement by a scalar value. |
Measurement |
mult(Measurement other)
Multiplies the other Measurement to this Measurement. |
protected Measurement |
multInternal(double scaling)
|
protected Measurement |
multInternal(Measurement other)
|
Measurement |
plus(Measurement other)
Adds the other Measurement to this Measurement. |
protected Measurement |
plusInternal(Measurement other)
|
Measurement |
pow(double power)
Raises this Measurement to the specified power. |
protected Measurement |
powInternal(double power)
|
Measurement |
root(double power)
Tales the root this Measurement by the specified power. |
protected Measurement |
rootInternal(double power)
|
java.lang.String |
toString()
A description of the measurement |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected transient double systemValue
protected static final int DIM_LENGTH
protected static final int DIM_TIME
protected static final int DIM_MASS
protected static final int DIM_ANGLE
protected transient Unit[] dims
protected static double TOL
power
of a Unit
.
Constructor Detail |
public BaseUnit(double value)
public BaseUnit()
Method Detail |
public Measurement plus(Measurement other) throws MeasurementException
Measurement
Adds the other Measurement to this Measurement.
Depending on the implementation, this may or may not alter this object.
plus
in interface Measurement
other
- The Measurement that is added to this Measurement
Measurement
object that reflects the result of this addition.
MeasurementException
- if both Measurements cannot be added.
This could occur if they were not referring to the same SystemOfUnits
.
This could occur if they did not possess the exact same array of Unit
s.
Measurement.getSystem()
,
Measurement.getSystemDimensions()
public Measurement minus(Measurement other) throws MeasurementException
Measurement
Subtracts the other Measurement to this Measurement.
Depending on the implementation, this may or may not alter this object.
minus
in interface Measurement
other
- The Measurement that is subtracted to this Measurement
Measurement
object that reflects the result of this subtraction.
MeasurementException
- if both Measurements cannot be subtracted.
This could occur if they were not referring to the same SystemOfUnits
.
This could occur if they did not possess the exact same array of Unit
s.
Measurement.getSystem()
,
Measurement.getSystemDimensions()
public Measurement mult(double scaling)
Measurement
Multiplies this Measurement
by a scalar value. This does not affect the Unit
s of the Measurement.
Depending on the implementation, this may or may not alter this object.
For example, if the Measurement represents five meters per second (5 [m / s]), and it is multiplied by 2, then the result will be ten meters per second (10 [m / s]).
mult
in interface Measurement
scaling
- A scalar value that multiplies this Measurement
Measurement
object that reflects the result of this multiplicationpublic Measurement mult(Measurement other)
Measurement
Multiplies the other Measurement to this Measurement.
Depending on the implementation, this may or may not alter this object.
mult
in interface Measurement
other
- The Measurement that is multiplied by this Measurement
Measurement
object that reflects the result of this multiplicationpublic Measurement div(double scaling)
Measurement
Divides this Measurement
by a scalar value. This does not affect the Unit
s of the Measurement.
Depending on the implementation, this may or may not alter this object.
For example, if the Measurement represents five meters per second (5 [m / s]), and it is divided by 2, then the result will be two-and-a-half meters per second (2.5 [m / s]).
div
in interface Measurement
scaling
- A scalar value that multiplies this Measurement
Measurement
object that reflects the result of this multiplicationpublic Measurement div(Measurement other)
Measurement
Divides this Measurement by the other Measurement.
Depending on the implementation, this may or may not alter this object.
div
in interface Measurement
other
- The Measurement that divided into this Measurement
Measurement
object that reflects the result of this divisionpublic Measurement pow(double power)
Measurement
Raises this Measurement
to the specified power.
Depending on the implementation, this may or may not alter this object.
For example, if the Measurement represents five meters per second (5 [m / s]), and it is raised to the power of two, the result will be twenty-five meters squared per second squared (25 [m^2 / s^2]).
pow
in interface Measurement
power
- The power that this Measurement is raised to
Measurement
object that reflects the result of raising the Measurement
to the desired powerMeasurement.root(double)
public Measurement root(double power)
Measurement
Tales the root this Measurement
by the specified power.
Depending on the implementation, this may or may not alter this object.
For example, if the Measurement represents nine square meters (9 [m^2]), and the square root is taken (power = 2), the result will be three meters (3 [m]).
root
in interface Measurement
power
- The power that this Measurement is lowered by
Measurement
object that reflects the result of lowering the Measurement
by the desired powerMeasurement.pow(double)
public Measurement copy()
Measurement
copy
in interface Measurement
Measurement
that is "equivalent" in value
to this Measurement.protected BaseUnit copyBaseUnit()
protected Measurement plusInternal(Measurement other) throws MeasurementException
MeasurementException
protected Measurement minusInternal(Measurement other) throws MeasurementException
MeasurementException
protected Measurement multInternal(double scaling)
protected Measurement multInternal(Measurement other)
protected Measurement divInternal(double scaling)
protected Measurement divInternal(Measurement other)
protected Measurement powInternal(double power)
protected Measurement rootInternal(double power)
public java.lang.String getAbbr()
Measurement
getAbbr
in interface Measurement
public java.lang.String getDescription()
Measurement
getDescription
in interface Measurement
public SystemOfUnits getSystem()
Measurement
The system of units being used by this Measurement.
Knowledge of SystemOfUnits
being used is vital for proper implementations of
any of the arithmetic methods: Measurement.plus(Measurement)
, Measurement.minus(Measurement)
, Measurement.mult(Measurement)
, Measurement.div(Measurement)
.
Both Measurements must reference the same SystemOfUnits for a proper comparison.
For example, if Person A weighs items in terms of kilograms, and Person B weighs items in terms of pounds, then they must both agree on a common system of units before they can properly compare weights. Their decision could be to measure items using the SI system of units, Imperial system of units, or perhaps some other one.
getSystem
in interface Measurement
system of units
being used by this Measurement
.Measurement.getSystemDimensions()
public Unit[] getSystemDimensions()
Measurement
An array of Unit
s within the SystemOfUnits
being used by this Measurement.
This array of Dimensions is vital for proper implementations of
any of the arithmetic methods: Measurement.plus(Measurement)
, Measurement.minus(Measurement)
, Measurement.mult(Measurement)
, Measurement.div(Measurement)
,
Measurement.pow(double)
, Measurement.root(double)
.
For example, if this Measurement measures the speed of five meters per second, then this method would return an array of Dimensions that contains:
getSystemDimensions
in interface Measurement
Unit
s being used by this Measurement
.Measurement.getSystem()
public double getSystemValue()
Measurement
The internal value of this measurement. Meant to be used in the implementations of the other methods.
For example, an implementation might store the value of the measurement
as a multiple of the "standard units" of the SystemOfUnits
being used.
getSystemValue
in interface Measurement
Measurement
.public boolean isSameMeasurementType(Measurement other)
public double getValue(Measurement multipleOf)
Measurement
getValue
in interface Measurement
multipleOf
- The Measurement to compared with
Measurement
as a multiple of the input parameter.public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |