public class Unit extends java.lang.Object implements UnitPresentation
This class also contains methods for operating on Units, such as multiply, divide, etc.
Red (rowland) |
Red (rowland) |
Modifier and Type | Field and Description |
---|---|
(package private) java.util.Vector |
_labels |
(package private) int[] |
_type |
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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() |
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.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.