|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.rubecula.util.Item
com.rubecula.jquantity.BaseNumber
com.rubecula.jquantity.JQuantity
This class represents a quantity, that is to say a value and its units. A quantity is immutable.
Methods of BaseNumber are generally delegated via the private field _Number. All methods of Measurable are delegated via the private field _Units. Although this class does not implement Divisible, it emulates it (where the return types are different and where the divide method is missing, since JQuantity is not mutable).
Copyright: Copyright (c) 2002, 2003
Company: Rubecula Software
| Field Summary | |
private BaseNumber |
_Number
The value of this JQuantity. |
private Measurable |
_Units
The units of this JQuantity. |
static JQuantity |
$1
|
static PresentationFactoryInterface |
$PRES_FACTORY
|
| Fields inherited from class com.rubecula.jquantity.BaseNumber |
|
| Fields inherited from class com.rubecula.util.Item |
JQUANTITY_TEST |
| Fields inherited from interface com.rubecula.jquantity.Fuzzy |
$DistGaussian, $DistInvalid, $DistNone, $DistUniform, $Names |
| Constructor Summary | |
JQuantity(BaseNumber number)
Constructor for a new dimensionless JQuantity. |
|
JQuantity(BaseNumber number,
Measurable units)
Primary constructor for a new JQuantity. |
|
JQuantity(java.lang.String presentation)
Constructs a dimensionless JQuantity from a String representing a number. |
|
JQuantity(java.lang.String presentation,
Units units)
Constructs a JQuantity from a String representing a number and a Units. |
|
| Method Summary | |
java.lang.String |
audit(java.lang.String label)
Method to implement com.rubecula.util.Auditable. |
java.lang.Object |
clone()
Creates and returns a copy of this JQuantity. |
int |
compareTo(JQuantity q)
Method to implement java.lang.Comparable. |
JQuantity |
convertUnits(Measurable newUnits)
|
protected JQuantity |
convertUnits(SystemFlag system)
|
(package private) Measurable |
createUnits(UnitsName name,
SystemFlag system)
Create a new unit from this quantity and call it by name. |
double |
doubleValue()
Method to implement java.lang.Number. |
Divisible |
factored(double factor)
Method to yield the quotient of this divided by factor, and return it as the result. |
BaseUnit |
flatten()
Method to reduce a Units tree to a single flattened version. |
float |
floatValue()
Method to implement java.lang.Number. |
Dimensions |
getDimensions()
Method to return the dimensions of this Measurable. |
java.lang.String |
getIdentifier()
Method to get the specific identifier for an object. |
protected BaseNumber |
getNumber()
Accessor method to get the number represented by this JQuantity. |
Rational |
getOffset()
Method to return the offset of this Measurable. |
Rational |
getScale()
Method to return the scale of this Measurable. |
SystemFlag |
getSystem()
|
protected Measurable |
getUnit()
Accessor method to get the unit represented by this JQuantity. |
int |
intValue()
Returns the value of the specified number as an int.
|
Divisible |
inverse()
Method to yield the reciprocal of this and return it as the result. |
boolean |
isInfinite()
Method to implement Arithmetical. |
boolean |
isInteger()
Method to implement Arithmetical. |
boolean |
isNumber()
Method to determine if this is dimensionless (i.e. unitless). |
boolean |
isParallel(Measurable that)
Method to determine if this Measurable is parallel to that Measurable. |
boolean |
isUnity()
Method to implement Arithmetical. |
long |
longValue()
Returns the value of the specified number as a long.
|
static void |
main(java.lang.String[] args)
Main method for testing purposes. |
Presentable |
makePresentableInstance(Presentation presentation)
Instance method to convert a Presentation into a Presentable. |
protected BaseNumber |
minus()
Method to implement BaseNumber. |
void |
normalize()
MUTATING instance method to normalize this object. |
protected void |
normalize(Measurable units)
MUTATING instance method to normalize this object by setting the units as specified and adjusting the value accordingly. |
protected BaseNumber |
pow(int power)
Method to raise this to the power power return the result. |
Presentation |
present(AttrMap attributes)
Convert this Presentable object into a Presentation, according to the set of attributes provided. |
BaseNumber |
product(BaseNumber multiplicand)
Method to implement form the product of this JQuantity and a BaseNumber. |
(package private) JQuantity |
productJQuantity(JQuantity that,
boolean standardize)
Method to multiply two Quantities together. |
Divisible |
quotient(BaseNumber divisor)
Method to divide this by multiplicand and return the quotient as the result. |
(package private) JQuantity |
quotientJQuantity(JQuantity that)
Method to divide two Quantities. |
protected BaseNumber |
scaled(long scale)
Method to multiply this quantity by an integral scale factor. |
int |
signum()
Method to implement Arithmetical. |
protected JQuantity |
standardizeUnits(SystemFlag system)
|
protected BaseNumber |
sum(BaseNumber addend)
Method to determine the sum of a quantity with a base number. |
private JQuantity |
sum(JQuantity addend)
Method to add two quantities together. |
static BaseNumber |
valueOf(Presentable presentable)
|
static BaseNumber |
valueOf(java.lang.String presentation)
Constructs a dimensionless JQuantity from a String representing a number. |
| Methods inherited from class com.rubecula.jquantity.BaseNumber |
abs, bestModel, BestModel, byteValue, characteristic, Characteristic, difference, getBound, getBoundAbs, getModel, impartFuzziness, isEqual, isExact, isUncertain, isZero, shortValue, valueOf, valueOfLog10 |
| Methods inherited from class com.rubecula.util.Item |
audit, audit, compareTo, Debug, getClassNameShort, getType, IsDebug, present, SetDebug, test, test, toString, Wrap |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.rubecula.util.Auditable |
audit, audit |
| Field Detail |
public static final JQuantity $1
public static final PresentationFactoryInterface $PRES_FACTORY
private final BaseNumber _Number
private final Measurable _Units
| Constructor Detail |
public JQuantity(BaseNumber number,
Measurable units)
number - the value of the new JQuantity which can be an instance
of any concrete subclass of MutableNumber.units - the units of the new JQuantity.public JQuantity(BaseNumber number)
number - the value of the new JQuantity which can be an instance
of any concrete subclass of MutableNumber.
public JQuantity(java.lang.String presentation,
Units units)
throws PresentationException
presentation - representation of number in the form understood byunits - the units to be used for this quantity.
PresentationException - if unable to parse appropriately.NumberPresentation.NumberPresentation(String).
public JQuantity(java.lang.String presentation)
throws PresentationException
presentation - representation of number in the form understood by
PresentationException - if unable to parse appropriately.JQuantity(String, Units).| Method Detail |
public static void main(java.lang.String[] args)
args - command line arguments.
public static final BaseNumber valueOf(java.lang.String presentation)
throws PresentationException
presentation - representation of number in the form understood by
PresentationException - if unable to parse appropriately.QuantityPresentation.valueOf(String)public static final BaseNumber valueOf(Presentable presentable)
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException - : not Cloneable (should be impossible)Cloneablepublic Divisible inverse()
inverse in interface Divisible
public Divisible quotient(BaseNumber divisor)
throws InvalidOperandException
quotient in interface Divisibledivisor - the number to multiply by this.
InvalidOperandException - operands are not compatible for the
quotient operation.public java.lang.String getIdentifier()
getIdentifier in interface Identifiablepublic boolean isInteger()
isInteger in interface Arithmeticalpublic int compareTo(JQuantity q)
q - the comparand object.
public BaseNumber product(BaseNumber multiplicand)
throws InvalidOperandException
product in class BaseNumbermultiplicand - the number which is to be multiplied by this.
InvalidOperandException - operands are not compatible for the
quotient operation.public double doubleValue()
doubleValue in class BaseNumberpublic float floatValue()
floatValue in class BaseNumberpublic int intValue()
BaseNumberint.
This may involve rounding or truncation.
intValue in class BaseNumberpublic long longValue()
BaseNumberlong.
This may involve rounding or truncation.
longValue in class BaseNumberpublic boolean isInfinite()
isInfinite in interface Arithmeticalpublic boolean isUnity()
isUnity in interface Arithmeticalpublic int signum()
signum in interface Arithmeticalpublic java.lang.String audit(java.lang.String label)
audit in interface Auditablelabel - the label which is to be embedded into the result (may be null).
public Presentation present(AttrMap attributes)
throws PresentationException
Presentable
present in interface Presentableattributes - the map of attributes required for the resulting
presentation.
PresentationException - if unable to parse appropriately.
public Presentable makePresentableInstance(Presentation presentation)
throws PresentationException
makePresentableInstance in interface Presentablepresentation - of a number to be converted into a Presentable number.
PresentationException - if presentation cannot be parsed appropriately.
protected BaseNumber sum(BaseNumber addend)
throws InvalidOperandException
sum in class BaseNumberaddend - the number which is to be added to this.
InvalidOperandException - operands are not compatible for the
quotient operation.protected BaseNumber pow(int power)
BaseNumber
pow in class BaseNumberpower - the power to which this quantity is to be raised.
protected BaseNumber scaled(long scale)
scaled in class BaseNumberscale - the number which is to be multiplied by this.
protected BaseNumber minus()
minus in class BaseNumberpublic Dimensions getDimensions()
getDimensions in interface Measurablepublic Rational getScale()
getScale in interface Measurablepublic Rational getOffset()
getOffset in interface Measurablepublic BaseUnit flatten()
flatten in interface MeasurableJQuantityExceptionpublic boolean isNumber()
isNumber in interface Measurablepublic boolean isParallel(Measurable that)
isParallel in interface Measurablethat - the Measurable to compare.
public void normalize()
protected final void normalize(Measurable units)
units - the units into which this should be converted.protected final BaseNumber getNumber()
protected final Measurable getUnit()
final Measurable createUnits(UnitsName name,
SystemFlag system)
name - the name of the new Unit
private JQuantity sum(JQuantity addend)
throws InvalidOperandException,
java.lang.CloneNotSupportedException
addend - the quantity to add to this.
Provided that the two quantities are parallel, the addend will first
be normalized to be in the same units as this.
JQuantityException - if units are not parallel.
InvalidOperandException - operands are not compatible for the
quotient operation.
java.lang.CloneNotSupportedException
JQuantity productJQuantity(JQuantity that,
boolean standardize)
that - the multiplicand,
i.e. the quantity which is to be multiplied by this.standardize - true if you want the result in the standard units for the combined system.
JQuantity quotientJQuantity(JQuantity that)
that - the divisor.
public SystemFlag getSystem()
getSystem in interface Measurablepublic Divisible factored(double factor)
Divisible
factored in interface Divisiblefactor - the scale factor.
public JQuantity convertUnits(Measurable newUnits)
protected JQuantity convertUnits(SystemFlag system)
protected JQuantity standardizeUnits(SystemFlag system)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||