org.xspace.mx.physics.mutable
Class Immutable

java.lang.Object
  extended byorg.xspace.mx.physics.mutable.BaseUnit
      extended byorg.xspace.mx.physics.mutable.Immutable
All Implemented Interfaces:
Measurement, java.io.Serializable
Direct Known Subclasses:
ImmutableAngle, ImmutableLength, ImmutableMass, ImmutableTime

public class Immutable
extends BaseUnit

An immutable wrapper for any other unit.

Since:
0.1
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.xspace.mx.physics.mutable.BaseUnit
DIM_ANGLE, DIM_LENGTH, DIM_MASS, DIM_TIME, dims, systemValue, TOL
 
Constructor Summary
Immutable(Measurement protectThis)
          Creates a new instance of Immutable
 
Method Summary
 Measurement copy()
          Returns a new instance of a Measurement that is "equivalent" in value to this Measurement.
 Measurement div(double scaling)
          Divides this Measurement by a scalar value.
 Measurement div(Measurement other)
          Divides this Measurement by the other Measurement.
 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 Units 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.
 Measurement minus(Measurement other)
          Subtracts the other Measurement to this Measurement.
 Measurement mult(double scaling)
          Multiplies this Measurement by a scalar value.
 Measurement mult(Measurement other)
          Multiplies the other Measurement to this Measurement.
 Measurement plus(Measurement other)
          Adds the other Measurement to this Measurement.
 Measurement pow(double power)
          Raises this Measurement to the specified power.
 Measurement root(double power)
          Tales the root this Measurement by the specified power.
 java.lang.String toString()
          A description of the measurement
 
Methods inherited from class org.xspace.mx.physics.mutable.BaseUnit
isSameMeasurementType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Immutable

public Immutable(Measurement protectThis)
Creates a new instance of Immutable

Parameters:
protectThis - The other Measurement that will be protected.
Method Detail

copy

public Measurement copy()
Description copied from interface: Measurement
Returns a new instance of a Measurement that is "equivalent" in value to this Measurement.

Specified by:
copy in interface Measurement
Overrides:
copy in class BaseUnit

div

public Measurement div(double scaling)
Description copied from interface: Measurement

Divides this Measurement by a scalar value. This does not affect the Units 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]).

Specified by:
div in interface Measurement
Overrides:
div in class BaseUnit

div

public Measurement div(Measurement other)
Description copied from interface: Measurement

Divides this Measurement by the other Measurement.

Depending on the implementation, this may or may not alter this object.

Specified by:
div in interface Measurement
Overrides:
div in class BaseUnit

getAbbr

public java.lang.String getAbbr()
Description copied from interface: Measurement
An abbreviated description of the units of this Measurement

Specified by:
getAbbr in interface Measurement
Overrides:
getAbbr in class BaseUnit

getDescription

public java.lang.String getDescription()
Description copied from interface: Measurement
A description of the units of this Measurement

Specified by:
getDescription in interface Measurement
Overrides:
getDescription in class BaseUnit

getSystem

public SystemOfUnits getSystem()
Description copied from interface: 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.

Specified by:
getSystem in interface Measurement
Overrides:
getSystem in class BaseUnit

getSystemDimensions

public Unit[] getSystemDimensions()
Description copied from interface: Measurement

An array of Units 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:

Specified by:
getSystemDimensions in interface Measurement
Overrides:
getSystemDimensions in class BaseUnit

getSystemValue

public double getSystemValue()
Description copied from interface: 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.

Specified by:
getSystemValue in interface Measurement
Overrides:
getSystemValue in class BaseUnit

getValue

public double getValue(Measurement multipleOf)
Description copied from interface: Measurement
The value of this measurement relative to the dimensions of the input measurement.

Specified by:
getValue in interface Measurement
Overrides:
getValue in class BaseUnit

minus

public Measurement minus(Measurement other)
                  throws MeasurementException
Description copied from interface: Measurement

Subtracts the other Measurement to this Measurement.

Depending on the implementation, this may or may not alter this object.

Specified by:
minus in interface Measurement
Overrides:
minus in class BaseUnit
Throws:
MeasurementException

mult

public Measurement mult(double scaling)
Description copied from interface: Measurement

Multiplies this Measurement by a scalar value. This does not affect the Units 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]).

Specified by:
mult in interface Measurement
Overrides:
mult in class BaseUnit

mult

public Measurement mult(Measurement other)
Description copied from interface: Measurement

Multiplies the other Measurement to this Measurement.

Depending on the implementation, this may or may not alter this object.

Specified by:
mult in interface Measurement
Overrides:
mult in class BaseUnit

plus

public Measurement plus(Measurement other)
                 throws MeasurementException
Description copied from interface: Measurement

Adds the other Measurement to this Measurement.

Depending on the implementation, this may or may not alter this object.

Specified by:
plus in interface Measurement
Overrides:
plus in class BaseUnit
Throws:
MeasurementException

pow

public Measurement pow(double power)
Description copied from interface: 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]).

Specified by:
pow in interface Measurement
Overrides:
pow in class BaseUnit

root

public Measurement root(double power)
Description copied from interface: 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]).

Specified by:
root in interface Measurement
Overrides:
root in class BaseUnit

toString

public java.lang.String toString()
Description copied from class: BaseUnit
A description of the measurement

Overrides:
toString in class BaseUnit
Returns:
A string describing the Measurement