|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--ptolemy.data.Token
|
+--ptolemy.data.ScalarToken
Abstract base class for tokens that contain a scalar. This class defines methods for type conversion among different scalar tokens. The implementation in this base class just throws an exception. Derived class should override the methods that the corresponding conversion can be achieved without loss of information.
Instances of ScalarToken may have units. In the arithmetic methods add() and subtract(), the two operands must have the same units. Otherwise, an exception will be thrown. In the methods multiply() and divide(), the units of the resulting token will be computed automatically.
| Field Summary | |
protected int[] |
_unitCategoryExponents
The unit category exponents. |
| Constructor Summary | |
ScalarToken()
|
|
| Method Summary | |
protected int[] |
_addCategoryExponents(ScalarToken token)
Add the corresponding unit category exponents. |
protected boolean |
_areUnitsEqual(ScalarToken scalarToken)
Return true if the units of this token are the same as that of the argument token. |
protected int[] |
_copyOfCategoryExponents()
Return a copy of the unit category exponents array. |
protected boolean |
_isUnitless()
Return true if this token does not have a unit. |
protected int[] |
_subtractCategoryExponents(ScalarToken token)
Subtract the corresponding unit category exponents of the argument token from that of this token. |
abstract ScalarToken |
absolute()
Return a ScalarToken containing the absolute value of the value of this token. |
Complex |
complexValue()
Return the value of this token as a Complex. |
double |
doubleValue()
Return the value of this token as a double. |
FixPoint |
fixValue()
Return the value of this token as a FixPoint. |
Type |
getType()
Return the type of this token. |
int |
intValue()
Return the value of this token as an int. |
ScalarToken |
inUnitsOf(ScalarToken units)
Return a scalar token that contains the value of this token in the units of the argument token. |
abstract BooleanToken |
isLessThan(ScalarToken token)
Check whether the value of this token is strictly less than that of the argument token. |
long |
longValue()
Return the value of this token as a long integer. |
void |
setUnitCategory(int index)
Set the unit category this token belongs to. |
java.lang.String |
unitsString()
Return the string representation of the units of this token. |
| Methods inherited from class ptolemy.data.Token |
_notSupportedMessage, add, addReverse, convert, divide, divideReverse, equals, hashCode, isCloseTo, isCloseTo, isEqualTo, modulo, moduloReverse, multiply, multiplyReverse, one, subtract, subtractReverse, toString, zero |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected int[] _unitCategoryExponents
| Constructor Detail |
public ScalarToken()
| Method Detail |
public abstract ScalarToken absolute()
public Complex complexValue()
throws IllegalActionException
IllegalActionException - Always thrown
public double doubleValue()
throws IllegalActionException
IllegalActionException - Always thrownpublic Type getType()
getType in class Token
public FixPoint fixValue()
throws IllegalActionException
IllegalActionException - Always thrown.
public int intValue()
throws IllegalActionException
IllegalActionException - Always thrown.
public abstract BooleanToken isLessThan(ScalarToken token)
throws IllegalActionException
token - A token to compare against.IllegalActionException - If the type of the argument token
is incomparable with the type of this token.
public ScalarToken inUnitsOf(ScalarToken units)
throws IllegalActionException
units - A scalar token that represents a unit.IllegalActionException - If the unit category of the
argument token is not the same as that of this one.
public long longValue()
throws IllegalActionException
IllegalActionException - Always thrown.public void setUnitCategory(int index)
The - unit category index.public java.lang.String unitsString()
protected int[] _addCategoryExponents(ScalarToken token)
token - A token whose exponent will be added with the
exponents of this token.protected int[] _copyOfCategoryExponents()
protected boolean _areUnitsEqual(ScalarToken scalarToken)
scalarToken - A scalar token.protected boolean _isUnitless()
protected int[] _subtractCategoryExponents(ScalarToken token)
token - A token whose exponent will be subtracted from the
exponents of this token.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||