|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.data.Token
ptolemy.data.ScalarToken
ptolemy.data.UnsignedByteToken
A token that contains a byte number in the range 0 through 255. This UnsignedByteToken definition is in contrast to Java's definition of a byte as a number in the range -128 through 127.
Overflow and underflow are handled by returning the result of all operations modulo 256. Thus, the result is always in the range 0 through 255. Likewise, constructors of this class generate tokens whose values are the argument modulo 256. Note, for example, that UnsignedByteToken((byte)(-100)) generates a UnsignedByteToken representing the value 156, which is -100 modulo 256.
Note, also, that the byteValue() method returns a Java byte in the range -128 through 127. This is in contrast to the intValue(), longValue(), doubleValue(), and complexValue() methods which all return values in the range 0 through 255. The value returned by byteValue() is the value represented by the UnsignedByteToken but with 256 subtracted if this value is greater than 127. In other words, the result and the argument are equal modulo 256.
| Yellow (winthrop) |
| Green (neuendor) |
| Field Summary |
| 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 with the specified integer value. |
|
UnsignedByteToken(java.lang.String init)
Construct a UnsignedByteToken from the specified string. |
|
| Method Summary | |
protected ScalarToken |
_absolute()
Return a ScalarToken containing the absolute value of the value of this token. |
protected ScalarToken |
_add(ScalarToken rightArgument)
Return a new token whose value is the value of the argument Token added to the value of this Token. |
protected ScalarToken |
_bitwiseAnd(ScalarToken rightArgument)
Returns a token representing the bitwise AND of this token and the given token. |
protected ScalarToken |
_bitwiseNot()
Returns a token representing the bitwise NOT of this token. |
protected ScalarToken |
_bitwiseOr(ScalarToken rightArgument)
Returns a token representing the bitwise OR of this token and the given token. |
protected ScalarToken |
_bitwiseXor(ScalarToken rightArgument)
Returns a token representing the bitwise XOR of this token and the given token. |
protected ScalarToken |
_divide(ScalarToken rightArgument)
Return a new token whose value is the value of this token divided by the value of the argument token. |
protected BooleanToken |
_isCloseTo(ScalarToken rightArgument,
double epsilon)
Test whether the value of this token is close to the first argument, where "close" means that the distance between them is less than or equal to the second argument. |
protected BooleanToken |
_isLessThan(ScalarToken rightArgument)
Test for ordering of the values of this Token and the argument Token. |
protected ScalarToken |
_modulo(ScalarToken rightArgument)
Return a new token whose value is the value of this token modulo the value of the argument token. |
protected ScalarToken |
_multiply(ScalarToken rightArgument)
Return a new token whose value is the value of this token multiplied by the value of the argument token. |
protected ScalarToken |
_subtract(ScalarToken rightArgument)
Return a new token whose value is the value of the argument token subtracted from the value of this token. |
byte |
byteValue()
Return the value in this token as a byte, modulo 256. |
Complex |
complexValue()
Return the value of this token as a Complex. |
static UnsignedByteToken |
convert(Token token)
Convert the specified token into an instance of UnsignedByteToken. |
double |
doubleValue()
Return the value in the token as a double. |
boolean |
equals(java.lang.Object object)
Return true if the class of the argument is UnsignedByteToken, and it has the same value as this token. |
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 integer. |
ScalarToken |
leftShift(int bits)
Returns a token representing the result of shifting the bits of this token towards the most significant bit, filling the least significant bits with zeros. |
ScalarToken |
logicalRightShift(int bits)
Returns a token representing the result of shifting the bits of this token towards the least significant bit, filling the most significant bits with zeros. |
long |
longValue()
Return the value in the token as a long. |
Token |
one()
Returns a new UnsignedByteToken with value 1. |
ScalarToken |
rightShift(int bits)
Returns a token representing the result of shifting the bits of this token towards the least significant bit, filling the most significant bits with the sign of the value. |
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. |
static int |
unsignedConvert(byte value)
Convert a byte to an integer, treating the byte as an unsigned value in the range 0 through 255. |
Token |
zero()
Returns a new UnsignedByteToken with value 0. |
| Methods inherited from class ptolemy.data.ScalarToken |
_addCategoryExponents, _areUnitsEqual, _copyOfCategoryExponents, _isEqualTo, _isUnitless, _subtractCategoryExponents, absolute, add, addReverse, bitwiseAnd, bitwiseNot, bitwiseOr, bitwiseXor, divide, divideReverse, fixValue, inUnitsOf, isCloseTo, isEqualTo, isGreaterThan, isLessThan, modulo, moduloReverse, multiply, multiplyReverse, setUnitCategory, subtract, subtractReverse, unitsString |
| Methods inherited from class ptolemy.data.Token |
isCloseTo, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, pow, zeroReturnType |
| 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 byte byteValue()
byteValue in class ScalarTokenpublic Complex complexValue()
complexValue in class ScalarToken
public static UnsignedByteToken convert(Token token)
throws IllegalActionException
token - The token to be converted to a UnsignedByteToken.
IllegalActionException - If the conversion
cannot be carried out.public double doubleValue()
doubleValue in class ScalarTokenpublic boolean equals(java.lang.Object object)
object - An instance of Object.
public Type getType()
getType in class ScalarTokenpublic int hashCode()
public int intValue()
intValue in class ScalarTokenpublic ScalarToken leftShift(int bits)
leftShift in class ScalarTokenbits - The number of bits to shift.
public ScalarToken logicalRightShift(int bits)
logicalRightShift in class ScalarTokenbits - The number of bits to shift.
public long longValue()
longValue in class ScalarTokenpublic Token one()
one in class Tokenpublic ScalarToken rightShift(int bits)
rightShift in class ScalarTokenbits - The number of bits to shift.
public java.lang.String toString()
toString in class TokenScalarToken.unitsString()public static int unsignedConvert(byte value)
value - The byte to convert to an unsigned byte.
public Token zero()
zero in class Tokenprotected ScalarToken _absolute()
_absolute in class ScalarTokenprotected ScalarToken _add(ScalarToken rightArgument)
_add in class ScalarTokenrightArgument - The token to add to this token.
protected ScalarToken _bitwiseAnd(ScalarToken rightArgument)
_bitwiseAnd in class ScalarTokenprotected ScalarToken _bitwiseNot()
_bitwiseNot in class ScalarTokenprotected ScalarToken _bitwiseOr(ScalarToken rightArgument)
_bitwiseOr in class ScalarTokenprotected ScalarToken _bitwiseXor(ScalarToken rightArgument)
_bitwiseXor in class ScalarTokenprotected ScalarToken _divide(ScalarToken rightArgument)
_divide in class ScalarTokenrightArgument - The token to divide this token by.
protected BooleanToken _isCloseTo(ScalarToken rightArgument,
double epsilon)
_isCloseTo in class ScalarTokenrightArgument - The token to compare to this token.epsilon - The distance.
protected BooleanToken _isLessThan(ScalarToken rightArgument)
_isLessThan in class ScalarTokenrightArgument - The token to add to this token.
protected ScalarToken _modulo(ScalarToken rightArgument)
_modulo in class ScalarTokenrightArgument - The token to modulo this token by.
protected ScalarToken _multiply(ScalarToken rightArgument)
_multiply in class ScalarTokenrightArgument - The token to multiply this token by.
protected ScalarToken _subtract(ScalarToken rightArgument)
_subtract in class ScalarTokenrightArgument - The token to subtract from this token.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||