|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.data.Token
ptolemy.data.AbstractNotConvertibleToken
ptolemy.data.ArrayToken
A token that contains an array of tokens. The operations between arrays are defined pointwise, and require that the lengths of the arrays are the same. The elements of the ArrayToken will be converted to the least upper bound of their input types and zero length array tokens cannot be created.
| Green (cxh) |
| Green (neuendor) |
| Constructor Summary | |
ArrayToken(java.lang.String init)
Construct an ArrayToken from the specified string. |
|
ArrayToken(Token[] value)
Construct an ArrayToken with the specified token array. |
|
| Method Summary | |
protected Token |
_add(Token rightArgument)
Return a new token whose value is the value of the argument token added to the value of this token. |
protected Token |
_divide(Token rightArgument)
Return a new token whose value is the value of this token divided by the value of the argument token. |
protected BooleanToken |
_isCloseTo(Token token,
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 |
_isEqualTo(Token token)
Return a true-valued token if the argument is equal to this one. |
protected Token |
_modulo(Token rightArgument)
Return a new token whose value is the value of this token modulo the value of the argument token. |
protected Token |
_multiply(Token rightArgument)
Return a new token whose value is the value of this token multiplied by the value of the argument token. |
protected Token |
_subtract(Token rightArgument)
Return a new token whose value is the value of the argument token subtracted from the value of this token. |
static byte[] |
arrayTokenToUnsignedByteArray(ArrayToken dataArrayToken)
Convert an ArrayToken to an array of unsigned bytes. |
Token[] |
arrayValue()
Return an array of tokens populated with the contents of this array token. |
ArrayToken |
elementAdd(Token token)
Add the given token to each element of this array. |
ArrayToken |
elementDivide(Token token)
Divide each element of this array by the given token. |
ArrayToken |
elementModulo(Token token)
Modulo each element of this array by the given token. |
ArrayToken |
elementMultiply(Token token)
Multiply each element of this array by the given token. |
ArrayToken |
elementSubtract(Token token)
Subtract the given token from each element of this array. |
boolean |
equals(java.lang.Object object)
Return true if the class of the argument is ArrayToken and of the same length and the elements are equal to that of this token. |
Token |
getElement(int index)
Return the element at the specified index. |
Type |
getElementType()
Return the type contained in this ArrayToken. |
Type |
getType()
Return the type of this ArrayToken. |
int |
hashCode()
Return a hash code value for this token. |
int |
length()
Return the length of the contained token array. |
Token |
one()
Return a new ArrayToken representing the multiplicative identity. |
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 ArrayToken |
unsignedByteArrayToArrayToken(byte[] dataBytes)
Take an array of unsigned bytes and convert it to an ArrayToken. |
Token |
zero()
Returns a new ArrayToken representing the additive identity. |
| Methods inherited from class ptolemy.data.AbstractNotConvertibleToken |
add, addReverse, divide, divideReverse, isCloseTo, isEqualTo, modulo, moduloReverse, multiply, multiplyReverse, notSupportedDifferentClassesMessage, subtract, subtractReverse |
| 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 ArrayToken(Token[] value)
throws IllegalActionException
value - An array of tokens.
IllegalActionException - If the tokens in the array
do not have the same type, or the length of the given array is
zero.
public ArrayToken(java.lang.String init)
throws IllegalActionException
"{1, 2, 3}"
init - A string expression of an array.
IllegalActionException - If the string does
not contain a parsable array.| Method Detail |
public static byte[] arrayTokenToUnsignedByteArray(ArrayToken dataArrayToken)
dataArrayToken - to be converted to a unsigned byte array.
public Token[] arrayValue()
public ArrayToken elementAdd(Token token)
throws IllegalActionException
IllegalActionException - If the argument token is not
of a type that can be added to an element of this token.
public ArrayToken elementDivide(Token token)
throws IllegalActionException
IllegalActionException - If the argument token is not
of a type that can be divided into an element of this token.
public ArrayToken elementModulo(Token token)
throws IllegalActionException
IllegalActionException - If the argument token is not
of a type that can be used with modulo.
public ArrayToken elementMultiply(Token token)
throws IllegalActionException
IllegalActionException - If the argument token is
not of a type that can be multiplied to an element of this token.
public ArrayToken elementSubtract(Token token)
throws IllegalActionException
IllegalActionException - If the argument token is not
of a type that can be subtracted from an element of this token.public boolean equals(java.lang.Object object)
object - the object to compare with.
public Token getElement(int index)
index - The index of the desired element.
ArrayIndexOutOfBoundException - If the specified index is
outside the range of the token array.public Type getElementType()
public Type getType()
getType in class Tokenpublic int hashCode()
public int length()
public Token one()
throws IllegalActionException
one in class TokenIllegalActionException - If multiplicative identity is not
supported by the element token.public java.lang.String toString()
toString in class Token
public static ArrayToken unsignedByteArrayToArrayToken(byte[] dataBytes)
throws IllegalActionException
dataBytes - data to be converted to an ArrayToken.
IllegalActionException - If ArrayToken can not be created.
public Token zero()
throws IllegalActionException
zero in class TokenIllegalActionException - If additive identity is not
supported by an element token.
protected Token _add(Token rightArgument)
throws IllegalActionException
_add in class AbstractNotConvertibleTokenrightArgument - The token whose value we add to the value
of this token.
IllegalActionException - If the argument is an
ArrayToken of different length, or calling the add method of
an element token throws it.
protected Token _divide(Token rightArgument)
throws IllegalActionException
_divide in class AbstractNotConvertibleTokenrightArgument - The token to divide this token by
IllegalActionException - If the argument is an
ArrayToken of different length, or calling the divide method
of the element token throws it.
protected BooleanToken _isCloseTo(Token token,
double epsilon)
throws IllegalActionException
_isCloseTo in class AbstractNotConvertibleTokentoken - The token to compare to this token.
IllegalActionException - If the elements do not support
this comparison.
protected BooleanToken _isEqualTo(Token token)
throws IllegalActionException
_isEqualTo in class AbstractNotConvertibleTokentoken - The token to compare to this token.
IllegalActionException - If the element types do not
support this comparison.
protected Token _modulo(Token rightArgument)
throws IllegalActionException
_modulo in class AbstractNotConvertibleTokenrightArgument - The token to modulo this token by.
IllegalActionException - If the argument is an
ArrayToken of different length, or calling the modulo method
of the element token throws it.
protected Token _multiply(Token rightArgument)
throws IllegalActionException
_multiply in class AbstractNotConvertibleTokenrightArgument - The token to multiply this token by.
IllegalActionException - If the argument is an
ArrayToken of different length, or calling the multiply method
of the element token throws it.
protected Token _subtract(Token rightArgument)
throws IllegalActionException
_subtract in class AbstractNotConvertibleTokenrightArgument - The token to subtract to this token.
IllegalActionException - If the argument is an
ArrayToken of different length, or calling the subtract method
of the element token throws it.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||