|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.moml.unit.Unit
public class Unit
Class that contains the internal representation of a Unit. A Unit has the mathematical notation S<E1, E2, ..., En> where S is the scale and <E1, E2, ..., En> is the type of the Unit.
This class also contains methods for operating on Units, such as multiply, divide, etc.
Red (rowland) |
Red (rowland) |
Field Summary | |
---|---|
(package private) java.util.Vector |
_labels
|
private static int |
_noLabelCounter
|
private double |
_scale
|
(package private) int[] |
_type
|
Constructor Summary | |
---|---|
Unit()
Create a Unit with no name and the unitless type. |
|
Unit(BaseUnit bu)
Create a Unit from a BaseUnit. |
|
Unit(java.lang.String name)
Create a Unit with a specified name, and the unitless type. |
Method Summary | |
---|---|
protected void |
_setLabels(java.util.Vector labels)
Set the labels of the Unit. |
Unit |
copy()
Make a copy of this Unit. |
java.lang.String |
descriptiveForm()
The expression of the Unit that is commonly used by humans. |
Unit |
divideBy(Unit divisor)
Divide this Unit by another Unit. |
boolean |
equals(java.lang.Object object)
Return True if this Unit equals another object |
UnitExpr |
factor()
Factor a Unit into a UnitExpr that has UnitTerms that are in the Library. |
java.util.Vector |
getLabels()
Get the labels for a Unit. |
java.lang.String |
getLabelsString()
Create a String that is the concatenation of all the labels. |
java.lang.String |
getPrimaryLabel()
Get the primary label of a Unit. |
double |
getScale()
Get the scale. |
int[] |
getType()
Get the type (represented as a int array) of this Unit. |
int |
hashCode()
Return a hash code value for this Unit. |
boolean |
hasSameType(Unit otherUnit)
Return true if the Unit has the same type as another Unit. |
Unit |
invert()
Invert this Unit. |
Unit |
multiplyBy(Unit multiplicand)
Multiply this Unit by another Unit. |
Unit |
pow(double power)
Returns of value of this Unit raised to the power of the argument. |
void |
setPrimaryLabel(java.lang.String label)
Set the primary label. |
void |
setScale(double d)
Set the scale. |
void |
setType(int[] type)
Set the type. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
java.util.Vector _labels
private static int _noLabelCounter
private double _scale
int[] _type
Constructor Detail |
---|
public Unit()
public Unit(BaseUnit bu)
bu
- BaseUnit that provides the basis for this Unit.public Unit(java.lang.String name)
name
- Name of the Unit.Method Detail |
---|
public Unit copy()
public java.lang.String descriptiveForm()
descriptiveForm
in interface UnitPresentation
UnitPresentation.descriptiveForm()
public Unit divideBy(Unit divisor)
divisor
- The divisor unit.
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- The object to be compared against.
public UnitExpr factor()
public java.util.Vector getLabels()
getPrimaryLabel()
public java.lang.String getLabelsString()
public java.lang.String getPrimaryLabel()
public double getScale()
public int[] getType()
public int hashCode()
hashCode
in class java.lang.Object
public boolean hasSameType(Unit otherUnit)
otherUnit
-
public Unit invert()
public Unit multiplyBy(Unit multiplicand)
multiplicand
-
public Unit pow(double power)
power
- The exponent.
public void setPrimaryLabel(java.lang.String label)
label
- The primary label.public void setScale(double d)
d
- The scale.public void setType(int[] type)
type
- public java.lang.String toString()
toString
in interface UnitPresentation
toString
in class java.lang.Object
protected void _setLabels(java.util.Vector labels)
labels
- The labels.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |