ptolemy.data
Class ArrayToken

java.lang.Object
  extended by ptolemy.data.Token
      extended by ptolemy.data.AbstractNotConvertibleToken
          extended by ptolemy.data.ArrayToken
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
UnsizedArrayToken

public class ArrayToken
extends AbstractNotConvertibleToken

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. Zero length array tokens are supported, given a prototype element to determine the type of the array.

Since:
Ptolemy II 0.4
Version:
$Id: ArrayToken.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Yuhong Xiong, Steve Neuendorffer, Contributor: Christopher Brooks
See Also:
Serialized Form
Accepted Rating:
Red (cxh) nil token code
Proposed Rating:
Yellow (cxh)

Field Summary
private  Type _elementType
          The type of this array.
private  Token[] _value
          The array of values of this array token.
static ArrayToken NIL
          A token that represents a missing value.
 
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.
ArrayToken(Type elementType)
          Construct an empty ArrayToken with the given element type.
ArrayToken(Type elementType, Token[] value)
          Construct an ArrayToken with the specified element type and 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.
private  void _checkArgumentLength(Token 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  Token _divideReverse(Token rightArgument)
          Return a new token whose value is the value of this token divided into 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 _moduloReverse(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.
protected  Token _subtractReverse(Token rightArgument)
          Return a new token whose value is the value of this token subtracted from the value of the argument token.
 Token add(Token rightArgument)
          Add this array token to the specified argument.
 Token addReverse(Token leftArgument)
          Add this array token to the specified argument.
 ArrayToken append(ArrayToken token)
          Append the given array to the end of this array, and return the resulting array.
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.
 BooleanToken contains(Token element)
          Return a Boolean token that identifies whether the given token is an element of this array.
 Token divide(Token rightArgument)
          Divide this array token by the specified argument.
 Token divideReverse(Token rightArgument)
          Divide this array token into the specified argument.
 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.
static Type elementMultiplyReturnType(Type type1, Type type2)
          Return the (exact) return type of the elementMultiply function above.
 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.
 ArrayToken extract(ArrayToken selection)
          Extract a non-contiguous subarray either by giving a boolean array of the same length of this array describing which elements to include and which to include, or by giving an an array of an arbitrary length giving the indices of elements from this array to include in the subarray.
 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.
 boolean isNil()
          Return true if the token is nil, (aka null or missing).
 int length()
          Return the length of the contained token array.
 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 rightArgument)
          Return a new token whose value is the value of the argument modulo the value of this token.
 Token multiply(Token rightArgument)
          Multiply this array token by the specified argument.
 Token multiplyReverse(Token leftArgument)
          Multiply this array token by the specified argument.
 Token one()
          Return a new ArrayToken representing the multiplicative identity.
 ArrayToken subarray(int index)
          Return the contiguous subarray starting at the specified index to the end of this array.
 ArrayToken subarray(int index, int count)
          Return the contiguous subarray starting at the specified index and of the specified length.
 Token subtract(Token rightArgument)
          Subtract from this array token the specified argument.
 Token subtractReverse(Token rightArgument)
          Subtract this array token from the specified argument.
 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
isCloseTo, isEqualTo, notSupportedDifferentClassesMessage
 
Methods inherited from class ptolemy.data.Token
isCloseTo, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, pow, zeroReturnType
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NIL

public static final ArrayToken NIL
A token that represents a missing value. Null or missing tokens are common in analytical systems like R and SAS where they are used to handle sparsely populated data sources. In database parlance, missing tokens are sometimes called null tokens. Since null is a Java keyword, we use the term "nil".


_value

private Token[] _value
The array of values of this array token.


_elementType

private Type _elementType
The type of this array.

Constructor Detail

ArrayToken

public ArrayToken(Token[] value)
           throws IllegalActionException
Construct an ArrayToken with the specified token array. The type of the resulting array is the least upper bound of the types of the elements. This class makes a copy of the given array, so the passed array may be reused. Note that this method cannot be used to create an empty array token, since the array token must have a type. Instead, use the constructor that takes a type argument or use the "emptyArray" function from the expression language.

Parameters:
value - An (not empty) array of tokens.
Throws:
IllegalActionException - If the length of the given array is zero.

ArrayToken

public ArrayToken(java.lang.String init)
           throws IllegalActionException
Construct an ArrayToken from the specified string. The format of the string is a list of comma separated token values that begins with "{" and ends with "}". For example "{1, 2, 3}"

Parameters:
init - A string expression of an array.
Throws:
IllegalActionException - If the string does not contain a parsable array.

ArrayToken

public ArrayToken(Type elementType)
Construct an empty ArrayToken with the given element type.

Parameters:
elementType - A token type.

ArrayToken

public ArrayToken(Type elementType,
                  Token[] value)
           throws IllegalActionException
Construct an ArrayToken with the specified element type and token array. All the tokens in the array must have the type of element type (or a subclass), otherwise an exception will be thrown. This class makes a copy of the given array, so the passed array may be reused.

Parameters:
elementType - The type of the array.
value - An array of tokens.
Throws:
IllegalActionException - If the tokens in the array do not have the specified type.
Method Detail

add

public Token add(Token rightArgument)
          throws IllegalActionException
Add this array token to the specified argument. If the argument is an array token and it has the same length as this array token then addition is elementwise. If the argument is an array of length one, then each element of this array is added to the argument. If this array has length one, then its value is added to each element of the argument, if it is an array. Otherwise, each element is multiplied by the argument. This overrides the base class to allow multiplication by scalars.

Overrides:
add in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token to multiply by this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument token is an array token but does not have the same length as this token, or if multiplication is not supported between the elements of this array and the argument.

addReverse

public Token addReverse(Token leftArgument)
                 throws IllegalActionException
Add this array token to the specified argument. If the argument is an array token and it has the same length as this array token then addition is elementwise. If the argument is an array of length one, then each element of this array is added to the argument. If this array has length one, then its value is added to each element of the argument, if it is an array. This overrides the base class to allow multiplication by scalars.

Overrides:
addReverse in class AbstractNotConvertibleToken
Parameters:
leftArgument - The token to multiply by this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument token is an array token but does not have the same length as this token, or if multiplication is not supported between the elements of this array and the argument.

append

public ArrayToken append(ArrayToken token)
                  throws IllegalActionException
Append the given array to the end of this array, and return the resulting array. For example, if this array is {1, 2, 3} and the given array is {4, 5, 6}, then the result would be {1, 2, 3, 4, 5, 6}. If both arrays are empty, then an empty array is returned.

Parameters:
token - The array to be appended to the end of this array.
Returns:
The result array.
Throws:
IllegalActionException - If an array token cannot be created.
Since:
Ptolemy II 7.1

arrayTokenToUnsignedByteArray

public static byte[] arrayTokenToUnsignedByteArray(ArrayToken dataArrayToken)
Convert an ArrayToken to an array of unsigned bytes.

Parameters:
dataArrayToken - to be converted to a unsigned byte array.
Returns:
dataBytes the resulting unsigned byte array.

arrayValue

public Token[] arrayValue()
Return an array of tokens populated with the contents of this array token. The returned array is a copy so the caller is free to modify it.

Returns:
An array of tokens.

contains

public BooleanToken contains(Token element)
Return a Boolean token that identifies whether the given token is an element of this array.

Parameters:
element - A token to test whether it is an element of this array.
Returns:
A true Boolean token if the element is found, or false otherwise.

divide

public Token divide(Token rightArgument)
             throws IllegalActionException
Divide this array token by the specified argument. If the argument is an array token and it has the same length as this array token, and the division is elementwise. Otherwise, each element is divided by the argument. This overrides the base class to allow division by scalars.

Overrides:
divide in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token to divide into this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument token is an array token but does not have the same length as this token, or if division is not supported between the elements of this array and the argument.

divideReverse

public Token divideReverse(Token rightArgument)
                    throws IllegalActionException
Divide this array token into the specified argument. If the argument is an array token and it has the same length as this array token, and the division is elementwise. Otherwise, each element is divided into the argument. This overrides the base class to allow division into scalars.

Overrides:
divideReverse in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token into which to divide this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument token is an array token but does not have the same length as this token, or if division is not supported between the elements of this array and the argument.

elementAdd

public ArrayToken elementAdd(Token token)
                      throws IllegalActionException
Add the given token to each element of this array.

Parameters:
token - The token to be added to this token.
Returns:
A new array token.
Throws:
IllegalActionException - If the argument token is not of a type that can be added to an element of this token.

elementDivide

public ArrayToken elementDivide(Token token)
                         throws IllegalActionException
Divide each element of this array by the given token.

Parameters:
token - The token which which to divide this token
Returns:
An array token.
Throws:
IllegalActionException - If the argument token is not of a type that can be divided into an element of this token.

elementModulo

public ArrayToken elementModulo(Token token)
                         throws IllegalActionException
Modulo each element of this array by the given token.

Parameters:
token - The token with which to modulo this token.
Returns:
An array token.
Throws:
IllegalActionException - If the argument token is not of a type that can be used with modulo.

elementMultiply

public ArrayToken elementMultiply(Token token)
                           throws IllegalActionException
Multiply each element of this array by the given token.

Parameters:
token - The token with which to multiply this token.
Returns:
An array token.
Throws:
IllegalActionException - If the argument token is not of a type that can be multiplied to an element of this token.

elementMultiplyReturnType

public static Type elementMultiplyReturnType(Type type1,
                                             Type type2)
                                      throws IllegalActionException
Return the (exact) return type of the elementMultiply function above. This returns a new array type whose element type is the least upper bound of the element type of this token and the given type.

Parameters:
type1 - The type of the base of the corresponding function.
type2 - The type of the argument of the corresponding function.
Returns:
The type of the value returned from the corresponding function.
Throws:
IllegalActionException - Not thrown in this base class.

elementSubtract

public ArrayToken elementSubtract(Token token)
                           throws IllegalActionException
Subtract the given token from each element of this array.

Parameters:
token - The token to subtract from this token.
Returns:
An array token.
Throws:
IllegalActionException - If the argument token is not of a type that can be subtracted from an element of this token.

equals

public 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. Equality of the contained elements is tested by their equals() method.

Overrides:
equals in class java.lang.Object
Parameters:
object - the object to compare with.
Returns:
True if the argument is an array token of the same length and the elements are equal to that of this token.

extract

public ArrayToken extract(ArrayToken selection)
                   throws IllegalActionException
Extract a non-contiguous subarray either by giving a boolean array of the same length of this array describing which elements to include and which to include, or by giving an an array of an arbitrary length giving the indices of elements from this array to include in the subarray. An example of the first form is {"red","green","blue"}.extract({true,false,true}), which evaluates to {"red", "blue"}. An example of the second form is {"red","green","blue"}.extract({2,0,1,1}), which evalues to {"blue", "red", "green", "green"}.

Parameters:
selection - An ArrayToken describing the selection of elements with which to form the subarray: either an array of integer indices, or an array of boolean inclusion/exclusion choices.
Returns:
An ArrayToken containing the extracted subarray.
Throws:
IllegalActionException - If the argument type is invalid or the result cannot be constructed.
java.lang.ArrayIndexOutOfBoundsException - If the argument is an array of integers, and one or more of those integers is not a valid index into this array.
Since:
Ptolemy II 4.1

getElement

public Token getElement(int index)
Return the element at the specified index.

Parameters:
index - The index of the desired element.
Returns:
The token contained in this array token at the specified index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the specified index is outside the range of the token array.

getElementType

public Type getElementType()
Return the type contained in this ArrayToken.

Returns:
A Type.

getType

public Type getType()
Return the type of this ArrayToken.

Overrides:
getType in class Token
Returns:
An ArrayType.

hashCode

public int hashCode()
Return a hash code value for this token. This method returns the hash code of the first element, unless the array is empty, in which case it returns the hashCode of the element type, unless there is no element type, in which case it returns the superclass hash code.

Overrides:
hashCode in class java.lang.Object
Returns:
A hash code value for this token.

isNil

public boolean isNil()
Return true if the token is nil, (aka null or missing). Nil or missing tokens occur when a data source is sparsely populated.

Overrides:
isNil in class Token
Returns:
True if the token is the NIL token.

length

public int length()
Return the length of the contained token array.

Returns:
The length of the contained token array.

modulo

public Token modulo(Token rightArgument)
             throws IllegalActionException
Return a new token whose value is the value of this token modulo the value of the argument token. This overrides the base class to allow modulo by scalars.

Overrides:
modulo in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token to divide into this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument token and this token are implemented in different classes, or the operation does not make sense for the given types.

moduloReverse

public Token moduloReverse(Token rightArgument)
                    throws IllegalActionException
Return a new token whose value is the value of the argument modulo the value of this token. This overrides the base class to allow modulo by scalars.

Overrides:
moduloReverse in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token to divide into this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument token and this token are implemented in different classes, or the operation does not make sense for the given types.

multiply

public Token multiply(Token rightArgument)
               throws IllegalActionException
Multiply this array token by the specified argument. If the argument is an array token and it has the same length as this array token, and the multiplication is elementwise. Otherwise, each element is multiplied by the argument. This overrides the base class to allow multiplication by scalars.

Overrides:
multiply in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token to multiply by this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument token is an array token but does not have the same length as this token, or if multiplication is not supported between the elements of this array and the argument.

multiplyReverse

public Token multiplyReverse(Token leftArgument)
                      throws IllegalActionException
Multiply this array token by the specified argument. If the argument is an array token and it has the same length as this array token, and the multiplication is elementwise. Otherwise, each element is multiplied by the argument. This overrides the base class to allow multiplication by scalars.

Overrides:
multiplyReverse in class AbstractNotConvertibleToken
Parameters:
leftArgument - The token to multiply by this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument token is an array token but does not have the same length as this token, or if multiplication is not supported between the elements of this array and the argument.

one

public Token one()
          throws IllegalActionException
Return a new ArrayToken representing the multiplicative identity. The returned token contains an array of the same size as the array contained by this token, and each element of the array in the returned token is the multiplicative identity of the corresponding element of this token.

Overrides:
one in class Token
Returns:
An ArrayToken.
Throws:
IllegalActionException - If multiplicative identity is not supported by the element token.

subarray

public ArrayToken subarray(int index)
                    throws IllegalActionException
Return the contiguous subarray starting at the specified index to the end of this array. If the specified index is out of range, then return an empty array with the same type as this array.

Parameters:
index - The index of the beginning of the subarray.
Returns:
The extracted subarray.
Throws:
IllegalActionException - If the index argument is less than zero.
Since:
Ptolemy II 7.1

subarray

public ArrayToken subarray(int index,
                           int count)
                    throws IllegalActionException
Return the contiguous subarray starting at the specified index and of the specified length. If the specified index is out of range, or if the specified length extends beyond the end of the array, then return an empty array with the same type as this array.

Parameters:
index - The index of the beginning of the subarray.
count - The length of the subarray.
Returns:
The extracted subarray.
Throws:
IllegalActionException - If the index argument is less than zero.
Since:
Ptolemy II 4.1

subtract

public Token subtract(Token rightArgument)
               throws IllegalActionException
Subtract from this array token the specified argument. If the argument is an array token and it has the same length as this array token, and the subtraction is elementwise. Otherwise, subtract the argument from each element. This overrides the base class to allow subtraction by scalars.

Overrides:
subtract in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token to subctract from this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument token is an array token but does not have the same length as this token or length 1, or if division is not supported between the elements of this array and the argument.

subtractReverse

public Token subtractReverse(Token rightArgument)
                      throws IllegalActionException
Subtract this array token from the specified argument. If the argument is an array token and it has the same length as this array token, and the subtraction is elementwise. Otherwise, each element is subtracted from the argument. This overrides the base class to allow subtraction from scalars.

Overrides:
subtractReverse in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token from which to subtract this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument token is an array token but does not have the same length as this token or length 1, or if division is not supported between the elements of this array and the argument.

toString

public 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.

Overrides:
toString in class Token
Returns:
A string beginning with "{" that contains expressions for every element in the array separated by commas, ending with "}".

unsignedByteArrayToArrayToken

public static ArrayToken unsignedByteArrayToArrayToken(byte[] dataBytes)
                                                throws IllegalActionException
Take an array of unsigned bytes and convert it to an ArrayToken.

Parameters:
dataBytes - data to be converted to an ArrayToken.
Returns:
dataArrayToken the resulting ArrayToken.
Throws:
IllegalActionException - If ArrayToken can not be created.

zero

public Token zero()
           throws IllegalActionException
Returns a new ArrayToken representing the additive identity. The returned token contains an array of the same size as the array contained by this token, and each element of the array in the returned token is the additive identity of the corresponding element of this token.

Overrides:
zero in class Token
Returns:
An ArrayToken.
Throws:
IllegalActionException - If additive identity is not supported by an element token.

_add

protected Token _add(Token rightArgument)
              throws IllegalActionException
Return a new token whose value is the value of the argument token added to the value of this token. It is assumed that this class is the class of the argument.

Specified by:
_add in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token whose value we add to the value of this token.
Returns:
A new array token containing the result.
Throws:
IllegalActionException - If the argument is an ArrayToken of different length, or calling the add method of an element token throws it.

_divide

protected Token _divide(Token rightArgument)
                 throws IllegalActionException
Return a new token whose value is the value of this token divided by the value of the argument token. If the argument is an array, then the division is done elementwise. Otherwise, this method assumes that each element can be divided by the argument and performs the division.

Specified by:
_divide in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token to divide this token by.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument is an ArrayToken of different length, or calling the divide method of the element token throws it.

_divideReverse

protected Token _divideReverse(Token rightArgument)
                        throws IllegalActionException
Return a new token whose value is the value of this token divided into the value of the argument token. If the argument is an array, then the division is done elementwise. Otherwise, this method assumes that the argument can be divided by each element of this array and performs the division.

Parameters:
rightArgument - The token into which to divide this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument is an ArrayToken of different length, or calling the divide method of the element token throws it.

_isCloseTo

protected BooleanToken _isCloseTo(Token token,
                                  double epsilon)
                           throws IllegalActionException
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. This method only makes sense for tokens where the distance between them is reasonably represented as a double. It is assumed that the argument is an ArrayToken, and the isCloseTo() method of the array elements is used.

Specified by:
_isCloseTo in class AbstractNotConvertibleToken
Parameters:
token - The token to compare to this token.
epsilon - The value that we use to determine whether two tokens are close.
Returns:
A true-valued token if the first argument is close to this token.
Throws:
IllegalActionException - If the elements do not support this comparison.

_isEqualTo

protected BooleanToken _isEqualTo(Token token)
                           throws IllegalActionException
Return a true-valued token if the argument is equal to this one. The isEqualTo() method of the element tokens is used to make the comparison. It is assumed that the argument is an ArrayToken.

Overrides:
_isEqualTo in class AbstractNotConvertibleToken
Parameters:
token - The token to compare to this token.
Returns:
A true-valued token if the argument is equal.
Throws:
IllegalActionException - If the element types do not support this comparison.

_modulo

protected Token _modulo(Token rightArgument)
                 throws IllegalActionException
Return a new token whose value is the value of this token modulo the value of the argument token. It is assumed that this class is the class of the argument.

Specified by:
_modulo in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token to modulo this token by.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument is an ArrayToken of different length, or calling the modulo method of the element token throws it.

_moduloReverse

protected Token _moduloReverse(Token rightArgument)
                        throws IllegalActionException
Return a new token whose value is the value of this token modulo the value of the argument token. If the argument is an array, then the modulo is done elementwise. Otherwise, this method assumes that the argument can be moduloed by each element of this array and performs the modulo.

Parameters:
rightArgument - The token into which to modulo this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument is an ArrayToken of different length, or calling the modulo method of the element token throws it.

_multiply

protected Token _multiply(Token rightArgument)
                   throws IllegalActionException
Return a new token whose value is the value of this token multiplied by the value of the argument token. If the argument is an array token, then it is required to have the same length as this array token, and the multiplication is performed elementwise. Otherwise, each element of this array is multiplied by the argument.

Specified by:
_multiply in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token to multiply this token by.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument is an ArrayToken of different length, or calling the multiply method of the element token throws it.

_subtract

protected Token _subtract(Token rightArgument)
                   throws IllegalActionException
Return a new token whose value is the value of the argument token subtracted from the value of this token. It is assumed that this class is the class of the argument.

Specified by:
_subtract in class AbstractNotConvertibleToken
Parameters:
rightArgument - The token to subtract to this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument is an ArrayToken of different length, or calling the subtract method of the element token throws it.

_subtractReverse

protected Token _subtractReverse(Token rightArgument)
                          throws IllegalActionException
Return a new token whose value is the value of this token subtracted from the value of the argument token. If the argument is an array with the same length as this one, then the division is done elementwise. Otherwise, this method assumes that the argument can be subtracted from each element of this array and performs the subtraction.

Parameters:
rightArgument - The token from which to subtract this token.
Returns:
A new token containing the result.
Throws:
IllegalActionException - If the argument is an ArrayToken of different length (and not length 1), or calling the subtract method of the element token throws it.

_checkArgumentLength

private void _checkArgumentLength(Token token)
                           throws IllegalActionException
Throws:
IllegalActionException