|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.rubecula.util.Item
com.rubecula.units.BaseUnit
com.rubecula.units.UnitsFoundation
com.rubecula.units.Units
This class extends UnitsFoundation by adding instance fields: _A, _B, _PowerA, _PowerB, _Scale, _Offset and _System.
New version of Units introduced February 2002.
In this new version, we make use of an Interface Measurable which provides
both the scale and the dimensions of a unit.
There are three implementers of Measurable:
This class is not yet fully implemented.
// TODO Consider extending java.util.Currency // TODO Ensure compliance. // TODO Change constant names to form $...
Field Summary | |
private Measurable |
_A
|
private Measurable |
_B
|
private Rational |
_Offset
|
private Rational |
_PowerA
|
private Rational |
_PowerB
|
private Rational |
_Scale
|
private SystemFlag |
_System
|
private static Rational |
$60
|
protected static java.lang.String |
$S_KG_PER_POUND
|
protected static java.lang.String |
$S_M_PER_FOOT
|
static java.lang.String |
AA
|
static java.lang.String |
AAC
|
private static java.lang.String |
AMP
|
static Units |
Ampere
|
private static java.lang.String |
ANGAM
|
private static java.lang.String |
ANGAS
|
private static java.lang.String |
ANGD
|
private static java.lang.String |
ANGG
|
private static java.lang.String |
ANGR
|
private static java.lang.String |
ANGX
|
static Units |
ArcMinute
|
static Units |
ArcSecond
|
private static Units[][] |
BaseUnits
|
static Units |
Candela
|
static Units |
Centimeter
|
private static java.lang.String |
CHRG
|
static Units |
Coulomb
|
private static java.lang.String |
CUSD
|
static Units |
Day
|
private static java.lang.String |
DEGC
|
private static java.lang.String |
DEGK
|
static java.lang.String |
DEGR
|
static Units |
Degree
|
static Units |
DollarUS
|
private static java.lang.String |
DSTA
|
static java.lang.String |
DSTAU
|
private static java.lang.String |
DSTCM
|
static java.lang.String |
DSTDM
|
private static java.lang.String |
DSTF
|
static java.lang.String |
DSTHM
|
static java.lang.String |
DSTI
|
static java.lang.String |
DSTKM
|
private static java.lang.String |
DSTLS
|
private static java.lang.String |
DSTM
|
private static java.lang.String |
DSTMM
|
static java.lang.String |
DSTY
|
static java.lang.String |
ERGE
|
private static java.lang.String |
ERGJ
|
static Units |
Flux
|
static Units |
Foot
|
static java.lang.String |
FRCD
|
private static java.lang.String |
FRCN
|
private static java.lang.String |
FREQ
|
static Units |
G
|
private static java.lang.String |
GMS
|
static Units |
Grad
|
static Units |
Gram
|
static Units |
GravConstUnits
|
static Units |
Henry
|
static Units |
Hertz
|
static Units |
Hour
|
static Rational |
Hundred
|
static Rational |
Hundredth
|
private static java.lang.String |
INDCT
|
static Units |
Joule
|
static Units |
Kelvin
|
static Units |
Kepler
|
static Units |
Kilogram
|
private static Units |
KilogramPerSecondSquared
|
private static java.lang.String |
LIGHT
|
static Units |
LightSecond
|
private static java.lang.String |
MASG
|
private static java.lang.String |
MASK
|
static java.lang.String |
MASO
|
private static java.lang.String |
MASP
|
static Units |
Meter
|
private static Units |
MeterCubed
|
static Units |
MeterPerSecond
|
static Units |
MeterPerSecondAllSquared
|
static Units |
MeterPerSecondSquared
|
private static java.lang.String |
MFD
|
private static java.lang.String |
MFLX
|
static Units |
Minute
|
static Units |
Mole
|
static Units |
Newton
|
static Units |
None
|
static Units |
Pascal
|
static Units |
Permeability
|
static Units |
PerMeter
|
static Units |
Permittivity
|
static Units |
Pound
|
private static java.lang.String |
POWW
|
private static java.lang.String |
PRSP
|
private static java.lang.String |
QTY
|
static Units |
Radian
|
static Units |
Rightangle
|
static Units |
Second
|
private static Units |
SecondSquared
|
static Rational |
Ten
|
static Rational |
Tenth
|
static Units |
Tesla
|
static Rational |
Thousand
|
static Rational |
Thousandth
|
private static java.lang.String |
TIMD
|
private static java.lang.String |
TIMH
|
private static java.lang.String |
TIMM
|
private static java.lang.String |
TIMS
|
private static java.lang.String |
TIMW
|
private static java.lang.String |
TIMY
|
private static java.lang.String |
VMS
|
static Units |
Volt
|
private static java.lang.String |
VOLT
|
static Units |
Watt
|
static Units |
Weber
|
private static java.lang.String |
ZFlux
|
private static java.lang.String |
ZKepler
|
private static java.lang.String |
ZPermeability
|
private static java.lang.String |
ZPermittivity
|
private static java.lang.String |
ZReciprocalMeter
|
Fields inherited from class com.rubecula.units.UnitsFoundation |
_Name, UNITS_TEST |
Fields inherited from class com.rubecula.util.Item |
JQUANTITY_TEST |
Constructor Summary | |
(package private) |
Units(Measurable base)
|
(package private) |
Units(java.lang.String name,
Measurable base)
|
(package private) |
Units(java.lang.String name,
Measurable base,
SystemFlag flag)
|
|
Units(UnitsName name,
SystemFlag system,
Rational scale,
Measurable A)
|
(package private) |
Units(UnitsName name,
SystemFlag system,
Rational scale,
Rational powerA,
Measurable A)
|
(package private) |
Units(UnitsName name,
SystemFlag system,
Rational scale,
Rational powerA,
Measurable A,
Rational powerB,
Measurable B)
|
(package private) |
Units(UnitsName name,
SystemFlag system,
Rational scale,
Rational powerA,
Measurable A,
Rational powerB,
Measurable B,
Rational offset)
|
Method Summary | |
(package private) void |
audit(int indent)
|
void |
audit(java.io.PrintStream out)
|
java.lang.Object |
clone()
Creates and returns a copy of this Units. |
(package private) Units |
combine(Rational powerA,
Measurable B,
Rational powerB)
|
int |
compareTo(Measurable val)
Compares this Units with the specified Measurable. |
int |
compareTo(java.lang.Object val)
Compares this Units with the specified Object. |
Measurable |
convertToSystem(int systemIndex)
method convertToSystem forces the system index of the result to be systemIndex (scaling as appropriate). |
(package private) Units |
difference(Measurable addend)
|
BaseUnit |
flatten()
Method to reduce a Units tree to a single flattened version. |
(package private) int |
getCommonSysIndex(Units that)
|
private java.lang.String |
getDescription()
|
Dimensions |
getDimensions()
Method to return the dimensions of this Measurable. |
Rational |
getOffset()
Method to return the offset of this Measurable. |
Rational |
getScale()
Method to return the scale of this Measurable. |
SystemFlag |
getSystem()
|
(package private) Units |
halve()
|
int |
hashCode()
|
boolean |
identity()
|
boolean |
isAngular()
|
(package private) boolean |
isEqual(Measurable other)
Method to determine if this BaseUnit is equivalent to that Measurable. |
boolean |
isInSystem(int sysIndex)
Method to determine if this Measurable is in a certain system of units. |
boolean |
isMutable()
This method indicates whether this particular instance is mutable, i.e. it has not been designated a constant. |
static void |
main(java.lang.String[] args)
|
Presentable |
makePresentableInstance(Presentation presentation)
Instance method to convert a Presentation into a Presentable. |
Units |
minus()
|
private void |
monitor(java.lang.String method,
java.lang.String arg0,
java.lang.String arg1,
java.lang.String arg2)
|
private static Rational |
nonZeroDivide(Rational num,
long denom)
|
Presentation |
present(AttrMap attributes)
Convert this Presentable object into a Presentation, according to the set of attributes provided. |
Units |
productScalar(Rational power)
|
(package private) Units |
rename(java.lang.String name)
|
(package private) Units |
scale(int scale)
Scale this unit. |
(package private) Units |
scale(Rational scale)
Scale this unit. |
(package private) Units |
scale(UnitsName name,
int scale)
Scale this unit and assign a new name to the result. |
(package private) Units |
scale(UnitsName name,
int scale,
SystemFlag system)
Scale this unit and assign a new name and system to the result. |
Units |
scale(UnitsName name,
Rational scale)
Scale this unit and assign a new name to the result. |
(package private) Units |
scale(UnitsName name,
Rational scale,
SystemFlag system)
Scale this unit and assign a new name and system to the result. |
Rational |
scaleToUnits(Measurable base,
Rational value)
This method converts value which is expressed in this Units into a value expressed in base units. |
Mutable |
setConstant()
This method sets this instance to be a constant, i.e. immutable. |
private static boolean |
stringComposite(java.lang.String string)
|
Units |
sum(Measurable addend)
|
static Measurable |
Sum(Measurable x,
Measurable y)
|
Units |
sum(Measurable addend,
Rational power)
|
java.lang.String |
toString()
This is the default toString method for all Items. |
java.lang.String |
toString(int sysIndex)
|
Methods inherited from class com.rubecula.units.UnitsFoundation |
audit, audit, audit, getIdentifier, isNumber, monitor, normalize, setIdentifier, setName, setName, setName, setName, setName, setName |
Methods inherited from class com.rubecula.units.BaseUnit |
isParallel, isParallelInSystem |
Methods inherited from class com.rubecula.util.Item |
Debug, getClassNameShort, getType, IsDebug, present, SetDebug, test, test, Wrap |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.rubecula.units.Measurable |
isNumber, isParallel |
Methods inherited from interface com.rubecula.util.Identifiable |
getIdentifier |
Methods inherited from interface com.rubecula.util.Auditable |
audit, audit, audit |
Field Detail |
private final SystemFlag _System
private final Rational _Scale
private final Rational _Offset
private final Rational _PowerA
private final Measurable _A
private final Rational _PowerB
private final Measurable _B
private static final java.lang.String ANGD
private static final java.lang.String ANGR
private static final java.lang.String ANGX
private static final java.lang.String ANGG
private static final java.lang.String ANGAS
private static final java.lang.String ANGAM
private static final java.lang.String CUSD
private static final java.lang.String DEGC
private static final java.lang.String DEGK
public static final java.lang.String DEGR
private static final java.lang.String DSTM
public static final java.lang.String DSTDM
public static final java.lang.String DSTHM
public static final java.lang.String DSTKM
private static final java.lang.String DSTCM
private static final java.lang.String DSTMM
private static final java.lang.String DSTA
private static final java.lang.String DSTF
public static final java.lang.String DSTI
public static final java.lang.String DSTY
public static final java.lang.String DSTAU
private static final java.lang.String DSTLS
private static final java.lang.String TIMS
private static final java.lang.String TIMM
private static final java.lang.String TIMH
private static final java.lang.String TIMD
private static final java.lang.String TIMY
private static final java.lang.String TIMW
private static final java.lang.String MASK
private static final java.lang.String MASG
private static final java.lang.String MASP
public static final java.lang.String MASO
private static final java.lang.String AMP
private static final java.lang.String CHRG
private static final java.lang.String ERGJ
public static final java.lang.String ERGE
private static final java.lang.String POWW
private static final java.lang.String LIGHT
private static final java.lang.String QTY
private static final java.lang.String VOLT
private static final java.lang.String FREQ
private static final java.lang.String FRCN
public static final java.lang.String FRCD
private static final java.lang.String PRSP
private static final java.lang.String MFLX
private static final java.lang.String INDCT
private static final java.lang.String MFD
public static final java.lang.String AA
public static final java.lang.String AAC
private static final java.lang.String VMS
private static final java.lang.String GMS
private static final java.lang.String ZPermeability
private static final java.lang.String ZPermittivity
private static final java.lang.String ZKepler
private static final java.lang.String ZReciprocalMeter
private static final java.lang.String ZFlux
public static Rational Ten
public static Rational Tenth
public static Rational Hundred
public static Rational Hundredth
public static Rational Thousand
public static Rational Thousandth
public static final Units None
public static final Units Meter
public static final Units Second
public static final Units Kilogram
public static final Units Radian
public static final Units Ampere
public static final Units Kelvin
public static final Units Candela
public static final Units Mole
public static final Units DollarUS
public static final Units Minute
public static final Units Hour
public static final Units Day
public static final Units Hertz
private static final Rational $60
public static final Units Degree
public static final Units ArcMinute
public static final Units ArcSecond
public static final Units Rightangle
public static final Units Grad
public static final Units Coulomb
public static final Units MeterPerSecond
public static final Units PerMeter
private static final Units MeterCubed
private static final Units SecondSquared
public static final Units MeterPerSecondSquared
private static final Units KilogramPerSecondSquared
public static final Units Newton
public static final Units Pascal
public static final Units GravConstUnits
public static final Units MeterPerSecondAllSquared
public static final Units Joule
public static final Units G
public static final Units Watt
public static final Units Volt
public static final Units Weber
public static final Units Henry
public static final Units Tesla
public static final Units Permeability
public static final Units Permittivity
public static final Units Kepler
public static final Units Flux
public static final Units Gram
public static final Units Centimeter
protected static final java.lang.String $S_M_PER_FOOT
protected static final java.lang.String $S_KG_PER_POUND
public static final Units LightSecond
public static final Units Pound
public static final Units Foot
private static final Units[][] BaseUnits
Constructor Detail |
Units(UnitsName name, SystemFlag system, Rational scale, Rational powerA, Measurable A, Rational powerB, Measurable B, Rational offset)
Units(UnitsName name, SystemFlag system, Rational scale, Rational powerA, Measurable A, Rational powerB, Measurable B)
Units(UnitsName name, SystemFlag system, Rational scale, Rational powerA, Measurable A)
public Units(UnitsName name, SystemFlag system, Rational scale, Measurable A)
Units(java.lang.String name, Measurable base, SystemFlag flag)
Units(java.lang.String name, Measurable base)
Units(Measurable base)
Method Detail |
public final int hashCode()
public java.lang.Object clone()
java.lang.Exception
- : not Cloneable (should be impossible)Cloneable
public int compareTo(Measurable val)
val
- Units to which this Measurable is to be compared.
public int compareTo(java.lang.Object val)
compareTo
in interface java.lang.Comparable
compareTo
in class Item
val
- Object to which this Units is to be compared.
Object.getClass()
,
Class.isInstance(java.lang.Object)
,
Class.getName()
,
Class.getSuperclass()
,
Method.invoke(java.lang.Object, java.lang.Object[])
,
Integer.intValue()
,
IllegalAccessException
,
InvocationTargetException
,
InvocationTargetException.getTargetException()
,
NoSuchMethodException
,
Class.getConstructor(java.lang.Class[])
,
Constructor.newInstance(java.lang.Object[])
public Dimensions getDimensions()
Measurable
getDimensions
in interface Measurable
public Rational getScale()
Measurable
getScale
in interface Measurable
public Rational getOffset()
Measurable
getOffset
in interface Measurable
final Units scale(UnitsName name, Rational scale, SystemFlag system)
name
- Name of scaled unitscale
- The scale.
For example, when creating an inch from a millimeter the
value of scale would be 254/10.system
- The system of the new unit.
public final Units scale(UnitsName name, Rational scale)
name
- Name of scaled unitscale
- The scale.
For example, when creating an inch from a millimeter the
value of scale would be 254/10.
final Units scale(Rational scale)
scale
- The scale.
For example, when creating an inch from a millimeter the
value of scale would be 254/10.
final Units scale(UnitsName name, int scale, SystemFlag system)
name
- Name of scaled unitscale
- The scale.
For example, when creating a minute from a second the
value of scale would be 60.system
- The system of the new unit.
final Units scale(UnitsName name, int scale)
name
- Name of scaled unitscale
- The scale.
For example, when creating a minute from a second the
value of scale would be 60.
final Units scale(int scale)
scale
- The scale.
For example, when creating a minute from a second the
value of scale would be 60.
final Units combine(Rational powerA, Measurable B, Rational powerB)
public final Units sum(Measurable addend, Rational power)
public final Units sum(Measurable addend)
final Units difference(Measurable addend)
public final Units productScalar(Rational power)
public final Units minus()
final Units halve() throws UnitsException
UnitsException
final Units rename(java.lang.String name)
public SystemFlag getSystem()
getSystem
in interface Measurable
public boolean isInSystem(int sysIndex)
BaseUnit
isInSystem
in class BaseUnit
sysIndex
- the index of the units system.
public BaseUnit flatten() throws UnitsException
Measurable
flatten
in interface Measurable
UnitsException
boolean isEqual(Measurable other)
BaseUnit
isEqual
in class BaseUnit
other
- the Measurable to compare.
public final Rational scaleToUnits(Measurable base, Rational value) throws UnitsException
base
- the units in which we want a value scaled.value
- the value to scale.
UnitsException
public java.lang.String toString(int sysIndex)
toString
in class UnitsFoundation
public java.lang.String toString()
Item
toString
in class UnitsFoundation
public void audit(java.io.PrintStream out)
public Presentation present(AttrMap attributes) throws PresentationException
present
in interface Presentable
attributes
- a map of the attributes desired for the construction
of the new presentation (may be empty).
PresentationException
- in case of parsing error.public Presentable makePresentableInstance(Presentation presentation) throws PresentationException
makePresentableInstance
in interface Presentable
presentation
- of a number to be converted into a Presentable number.
PresentationException
- in case of parsing error.private java.lang.String getDescription()
private static boolean stringComposite(java.lang.String string)
public final boolean identity() throws UnitsException
UnitsException
public final boolean isAngular() throws UnitsException
UnitsException
final int getCommonSysIndex(Units that)
final void audit(int indent)
private void monitor(java.lang.String method, java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)
private static Rational nonZeroDivide(Rational num, long denom)
public final Measurable convertToSystem(int systemIndex)
systemIndex
- the system in which we want the returned value to be.
public static void main(java.lang.String[] args)
public boolean isMutable()
Mutable
isMutable
in interface Mutable
public Mutable setConstant()
Mutable
setConstant
in interface Mutable
public static Measurable Sum(Measurable x, Measurable y)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |