Package ptolemy.data

Class ArrayToken

  • Direct Known Subclasses:
    UnsizedArrayToken, UpdatedArrayToken

    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$
    Author:
    Yuhong Xiong, Steve Neuendorffer, Contributor: Christopher Brooks
    Pt.AcceptedRating:
    Red (cxh) nil token code
    Pt.ProposedRating:
    Yellow (cxh)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int _depth
      The depth of the hierarchy of array tokens used to represent this array.
      protected Type _elementType
      The type of this array.
      static ArrayToken NIL
      A token that represents a missing value.
    • Constructor Summary

      Constructors 
      Constructor Description
      ArrayToken​(java.lang.String init)
      Construct an ArrayToken from the specified string.
      ArrayToken​(Token[] value)
      Construct an ArrayToken with the specified token array.
      ArrayToken​(Token[] value, int length)
      Construct an ArrayToken with the first length elements of 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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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 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)
      Addition can occur between arrays, or between an array and a token of some base type (i.e., anything less than or equal to String).
      Token addReverse​(Token leftArgument)
      If the left-hand argument is a base type token, then convert it to an array of size one.
      ArrayToken append​(ArrayToken token)
      Append the given array to the end of this array, and return the resulting array.
      static ArrayToken append​(ArrayToken[] tokens)
      Append the given arrays.
      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.
      BooleanToken isCloseTo​(Token token, double epsilon)
      Test that 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.
      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 reverse()
      Return a new ArrayToken whose elements are in reverse order of this ArrayToken.
      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.
      ArrayToken update​(int index, Token value)
      Return a new array with all elements equal to those of this array except the one at position index, which has value given by value.
      Token zero()
      Returns a new ArrayToken representing the additive identity.
      • 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".
      • _depth

        protected int _depth
        The depth of the hierarchy of array tokens used to represent this array. If this array is an instance of this base class, then the depth is 0. Subclasses, however, represent the array in terms of instances of ArrayToken, and in that case, the value of this variable will be the longest path in the hierarchy to the an instance of this ArrayToken class.
      • _elementType

        protected 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​(Token[] value,
                          int length)
                   throws IllegalActionException
        Construct an ArrayToken with the first length elements of the specified token array. If length is greater than the length of the specified array, then the resulting array token will have exactly the number of elements in the specified 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.
        length - The number of elements to be used from the specified array.
        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
        Addition can occur between arrays, or between an array and a token of some base type (i.e., anything less than or equal to String). Addition is undefined between arrays and tokens of other incomparable data types such as Record and Union.
        Overrides:
        add in class AbstractNotConvertibleToken
        Parameters:
        rightArgument - The array to be added to this array.
        Returns:
        The result of the addition.
        Throws:
        IllegalActionException - If addition between this array and the provided argument is not supported.
      • addReverse

        public Token addReverse​(Token leftArgument)
                         throws IllegalActionException
        If the left-hand argument is a base type token, then convert it to an array of size one. Then do an element-wise addition with each element of the right-hand argument. This method is only invoked when addition is attempted using a base type left-hand argument (e.g., 1 + {1, 2, 3} which will yield {2, 3, 4}.
        Overrides:
        addReverse in class AbstractNotConvertibleToken
        Parameters:
        leftArgument - The array to add this array to.
        Returns:
        The result of the addition.
        Throws:
        IllegalActionException - If addition between this array and the provided argument is not supported.
      • 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
      • append

        public static ArrayToken append​(ArrayToken[] tokens)
                                 throws IllegalActionException
        Append the given arrays.
        Parameters:
        tokens - The list of arrays to be appended together.
        Returns:
        The result array.
        Throws:
        IllegalActionException - If an array token cannot be created, or if all specified arrays are empty.
        Since:
        Ptolemy II 9.0
      • 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.
        See Also:
        unsignedByteArrayToArrayToken(byte[])
      • 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 evaluates 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.
      • isCloseTo

        public BooleanToken isCloseTo​(Token token,
                                      double epsilon)
                               throws IllegalActionException
        Test that 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 arrays where where the distance between elements is reasonably represented as a double. This class overrides the superclass to not insist that the two array tokens be instances of the same class, but rather that they just both be array tokens, and then defers to the _isCloseTo() method.
        Overrides:
        isCloseTo in class AbstractNotConvertibleToken
        Parameters:
        token - The token to test closeness of this token with.
        epsilon - The value that we use to determine whether two tokens are close.
        Returns:
        A boolean token that contains the value true if the value of this token is close to that of the argument token.
        Throws:
        IllegalActionException - If the argument token and this token are implemented in different classes.
      • 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 subtract 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 "}".
      • update

        public ArrayToken update​(int index,
                                 Token value)
                          throws IllegalActionException
        Return a new array with all elements equal to those of this array except the one at position index, which has value given by value. If the index is out of range, then return this array token unchanged. The element type of the new array is the least upper bound of the element type of this array and the specified value.
        Parameters:
        index - The index of the element to be updated.
        value - The value of the element to be updated.
        Returns:
        A new array.
        Throws:
        IllegalActionException - Should not be thrown in this base class.
      • 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.