|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.lang.Number
|
+--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 |
| 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,
Units 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. |
(package private) Units |
createUnits(java.lang.String name)
Create a new unit from this quantity and call it by name. |
double |
doubleValue()
Method to implement java.lang.Number. |
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. |
protected Units |
getUnit()
Accessor method to get the unit represented by this JQuantity. |
int |
intValue()
|
JQuantity |
inverse()
Method to yield the reciprocal of this and return it as the result. |
boolean |
isInfinite()
Method to implement Arithmetical. |
boolean |
isInSystem(int sysIndex)
Method to determine if this Measurable is in a certain system of units. |
boolean |
isInteger()
Method to implement Arithmetical. |
boolean |
isNumber()
Method to determine if this is dimensionless (i.e. |
boolean |
isParallel(Measurable that)
Method to determine if this Measurable is parallel to that Measurable. |
boolean |
isUnity()
Method to implement Arithmetical. |
long |
longValue()
|
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(Units 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)
Method to multiply two Quantities together. |
JQuantity |
quotient(BaseNumber divisor)
Method to divide this by multiplicand and return the quotient as the result. |
protected BaseNumber |
scaled(long scale)
Method to multiply this quantity by an integral scale factor. |
int |
signum()
Method to implement Arithmetical. |
protected BaseNumber |
sum(BaseNumber addend)
Method to determine the sum of a quantity with a base number. |
| Methods inherited from class com.rubecula.jquantity.BaseNumber |
abs, audit, audit, bestModel, BestModel, Characteristic, compareTo, difference, getBound, getBoundAbs, getModel, impartFuzziness, isEqual, isExact, isUncertain, isZero, present, test, test, toString, valueOfLog10, Wrap |
| Methods inherited from class java.lang.Number |
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public JQuantity(BaseNumber number,
Units 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(String).
public JQuantity(java.lang.String presentation)
throws PresentationException
presentation - representation of number in the form understood by
PresentationException - if unable to parse appropriately.NumberPresentation(String).| Method Detail |
public static void main(java.lang.String[] args)
args - command line arguments.public java.lang.Object clone()
clone in class java.lang.Objectjava.lang.Exception - : not Cloneable (should be impossible)Cloneablepublic JQuantity inverse()
public JQuantity quotient(BaseNumber divisor)
throws InvalidOperandException
divisor - the number to multiply by this.
InvalidOperandException - operands are not compatible for the
quotient operation.public java.lang.String getIdentifier()
getIdentifier in interface Auditablepublic 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 java.lang.Numberpublic float floatValue()
floatValue in class java.lang.Numberpublic int intValue()
intValue in class java.lang.Numberpublic long longValue()
longValue in class java.lang.Numberpublic 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 boolean isInSystem(int sysIndex)
sysIndex - the index of the units system.
public BaseUnit flatten()
JQuantityExceptionpublic boolean isNumber()
public boolean isParallel(Measurable that)
that - the Measurable to compare.
public void normalize()
protected final void normalize(Units units)
units - the units into which this should be converted.protected final BaseNumber getNumber()
protected final Units getUnit()
final Units createUnits(java.lang.String name)
name - the name of the new Unit
JQuantity productJQuantity(JQuantity that)
that - the multiplicand,
i.e. the quantity which is to be multiplied by this.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||