|
|||||||||
| 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
|
+--ptolemy.data.UnsignedByteToken
A token that contains an unsigned byte number in the range 0 through 255. This is in contrast to Java's default that a byte is in the range -128 through 127. To get our desired behavior we need only apply a custom conversion unsignedConvert() from byte to integer. Conversion to byte already gives the desired behavior of truncating the value, keeping the lowest 8 bits. Thus, for example, the integers -1 and 1023 both truncate to the byte 255. Throughout the code, casts (byte) to byte occur. These are necessary because Java converts to integer or higher by default when doing arithmetic. Java does this even when the types of both operands are byte.
| Fields inherited from class ptolemy.data.ScalarToken |
_unitCategoryExponents |
| Constructor Summary | |
UnsignedByteToken()
Construct a token with byte 0. |
|
UnsignedByteToken(byte value)
Construct a UnsignedByteToken with the specified byte value. |
|
UnsignedByteToken(int value)
Construct a UnsignedByteToken from the specified integer. |
|
UnsignedByteToken(java.lang.String init)
Construct a UnsignedByteToken from the specified string. |
|
| Method Summary | |
ScalarToken |
absolute()
Return a UnsignedByteToken containing the absolute value (which, for bytes, equals the value) of this token. |
Token |
add(Token rightArgument)
Return a new token whose value is the sum of this token and the argument. |
Token |
addReverse(Token leftArgument)
Return a new token whose value is the sum of this token and the argument. |
byte |
byteValue()
Return the value in the token as a byte. |
Complex |
complexValue()
Return the value of this token as a Complex. |
static Token |
convert(Token token)
Convert the specified token into an instance of UnsignedByteToken. |
Token |
divide(Token divisor)
Return a new token whose value is the value of this token divided by the value of the argument token. |
Token |
divideReverse(Token dividend)
Return a new token whose value is the value of the argument token divided by the value of this token. |
double |
doubleValue()
Return the value in the token as a double. |
boolean |
equals(java.lang.Object object)
Return true if the argument is an instance of UnsignedByteToken with the same value. |
Type |
getType()
Return the type of this token. |
int |
hashCode()
Return a hash code value for this token. |
int |
intValue()
Return the value in the token as an int. |
BooleanToken |
isEqualTo(Token token)
Test the value and units of this token and the argument token for equality. |
BooleanToken |
isLessThan(ScalarToken token)
Check if the value of this token is strictly less than that of the argument token. |
long |
longValue()
Return the value in the token as a long. |
Token |
modulo(Token rightArgument)
Return a new token whose value is the value of this token modulo the value of the argument token. |
Token |
moduloReverse(Token leftArgument)
Return a new token whose value is the value of the argument token modulo the value of this token. |
Token |
multiply(Token rightFactor)
Return a new token whose value is the value of this token multiplied by the value of the argument token. |
Token |
multiplyReverse(Token leftFactor)
Return a new token whose value is the value of the argument token multiplied by the value of this token. |
Token |
one()
Returns a new UnsignedByteToken with value 1. |
Token |
subtract(Token rightArgument)
Return a new token whose value is the value of the argument token subtracted from the value of this token. |
Token |
subtractReverse(Token leftArgument)
Return a new token whose value is the value of this token subtracted from the value of the argument token. |
java.lang.String |
toString()
Return the value of this token as a string that can be parsed by the expression language to recover a token with the same value. |
int |
unsignedConvert(byte value)
Convert the given unsigned byte to an integer. |
Token |
zero()
Returns a new UnsignedByteToken with value 0. |
| Methods inherited from class ptolemy.data.ScalarToken |
_addCategoryExponents, _areUnitsEqual, _copyOfCategoryExponents, _isUnitless, _subtractCategoryExponents, fixValue, inUnitsOf, setUnitCategory, unitsString |
| Methods inherited from class ptolemy.data.Token |
_notSupportedMessage, isCloseTo, isCloseTo |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public UnsignedByteToken()
public UnsignedByteToken(byte value)
public UnsignedByteToken(int value)
public UnsignedByteToken(java.lang.String init)
throws IllegalActionException
IllegalActionException - If the token could not
be created from the given string.| Method Detail |
public ScalarToken absolute()
absolute in class ScalarToken
public Token add(Token rightArgument)
throws IllegalActionException
add in class TokenrightArgument - The token to add to this token.IllegalActionException - If the argument token
is not of a type that can be added to this token, or
the units of this token and the argument token are not the same.
public Token addReverse(Token leftArgument)
throws IllegalActionException
addReverse in class TokenleftArgument - The token to add this token to.IllegalActionException - If the argument token
is not of a type that can be added to this token, or
the units of this token and the argument token are not the same.public Complex complexValue()
complexValue in class ScalarToken
public static Token convert(Token token)
throws IllegalActionException
token - The token to be converted to a UnsignedByteToken.IllegalActionException - If the conversion
cannot be carried out.
public Token divide(Token divisor)
throws IllegalActionException
divide in class Tokendivisor - The token to divide this token byIllegalActionException - If the argument token is
of a type that cannot divide this token.
public Token divideReverse(Token dividend)
throws IllegalActionException
divideReverse in class Tokendividend - The token to be divided by the value of this token.IllegalActionException - If the argument token
is not of a type that can be divided by this token's value.public double doubleValue()
doubleValue in class ScalarTokenpublic boolean equals(java.lang.Object object)
equals in class Tokenobject - An instance of Object.public Type getType()
getType in class ScalarTokenpublic int hashCode()
hashCode in class Token
public BooleanToken isEqualTo(Token token)
throws IllegalActionException
isEqualTo in class Tokentoken - The token with which to test equality.IllegalActionException - If the argument token is
not of a type that can be compared with this token.
public BooleanToken isLessThan(ScalarToken token)
throws IllegalActionException
isLessThan in class ScalarTokentoken - A ScalarToken.IllegalActionException - If the type of the argument token
is incomparable with the type of this token, or the units of this
token and the argument are not the same.public byte byteValue()
public int intValue()
intValue in class ScalarTokenpublic long longValue()
longValue in class ScalarToken
public Token modulo(Token rightArgument)
throws IllegalActionException
modulo in class TokenrightArgument - The token to modulo this token by.IllegalActionException - If the argument token is
not of a type that can be used with modulo, or the units of
this token and the argument token are not the same.
public Token moduloReverse(Token leftArgument)
throws IllegalActionException
moduloReverse in class TokenleftArgument - The token to apply modulo to by the value of
this token.IllegalActionException - If the argument token
is not of a type that can apply modulo by this token, or
if the units of this token are not the same as those of the
argument.
public Token multiply(Token rightFactor)
throws IllegalActionException
multiply in class TokenrightFactor - The token to multiply this token by.IllegalActionException - If the argument token is
not of a type that can be multiplied to this token.
public Token multiplyReverse(Token leftFactor)
throws IllegalActionException
multiplyReverse in class TokenleftFactor - The token to be multiplied by the value of
this token.IllegalActionException - If the argument token
is not of a type that can be multiplied by this token.public Token one()
one in class Token
public Token subtract(Token rightArgument)
throws IllegalActionException
subtract in class TokenrightArgument - The token to subtract from this token.IllegalActionException - If the argument token is
not of a type that can be subtracted from this token, or the units
of this token and the argument token are not the same.
public Token subtractReverse(Token leftArgument)
throws IllegalActionException
subtractReverse in class TokenleftArgument - The token to subtract this token from.IllegalActionException - If the argument token is not
of a type that can be added to this token, or the units of
this token and the argument token are not the same.
FIXME: byte (and int too) have less code in the
subtractReverse() method. Something is not being handled
here. CPO is not even being checked!!public java.lang.String toString()
toString in class TokenScalarToken.unitsString()public int unsignedConvert(byte value)
byte - The byte to convert.public Token zero()
zero in class Token
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||