Class BluetoothResponseToken<T>

  • Type Parameters:
    T - - the type for the data contained within this token.

    public class BluetoothResponseToken<T>
    extends BluetoothToken
    A wireless response from one BluetoothDevice actor to another. It is essentially reimagining of the ObjectToken type, with a few more members critical to making the Bluetooth to Bluetooth communication possible. These include a device identifier, a source identifier, and data.

    The device identifier field represents the target device for this response token. The source identifier field represents the current device this response token is bieng sent from. This will be set to the return value of this.getName() in all cases except when scanning, where it will be set to "scan". The data field represents an arbitrary peice of data to communicate to another BluetoothDevice actor.

    Construction of an object of this class requires a BluetoothResponse enum element, a device identifier, a source identifier, and an arbitrary piece of data. The fields of this class are immutable.

    The toString() method will return the string equivalent of the BluetoothResponse enum element contained within this object.

    Since:
    Ptolemy II 11.0
    Version:
    $Id$, $Id$
    Author:
    Phillip Azar
    See Also:
    BluetoothResponse, BluetoothDevice
    • Constructor Detail

      • BluetoothResponseToken

        public BluetoothResponseToken​(BluetoothResponse response,
                                      java.lang.String deviceIdentifier,
                                      java.lang.String sourceIdentifier,
                                      T data)
        Construct a BluetoothResposeToken.
        Parameters:
        response - The response, request, or command desired. Acceptable entries are contained within the BluetoothResponse enumeration.
        deviceIdentifier - A String representing the name of target device.
        sourceIdentifier - A String representing the name of the device constructing this token.
        data - The arbitrary data to send.
    • Method Detail

      • getResponse

        public BluetoothResponse getResponse()
        Get the BluetoothResponse enum element associated with this token.
        Returns:
        _response
      • getDeviceIdentifier

        public java.lang.String getDeviceIdentifier()
        Get the name of the target device associated with this token.
        Returns:
        _deviceIdentifier
      • getSourceIdentifier

        public java.lang.String getSourceIdentifier()
        Get the name of the source device associated with this token.
        Returns:
        _sourceIdentifier
      • getData

        public T getData()
        Get the data stored within this token.
        Returns:
        _data
      • toString

        public java.lang.String toString()
        Description copied from class: Token
        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. This method should be overridden by derived classes. In this base class, return the String "present" to indicate that an event is present. If this token is Token.NIL then return "nil"
        Overrides:
        toString in class Token
        Returns:
        The String "present", unless this token is Token.NIL, in which case return the String "nil".
      • isEqualTo

        public BooleanToken isEqualTo​(Token rightArgument)
                               throws IllegalActionException
        Description copied from class: Token
        Test for equality of the values of this Token and the argument Token.
        Overrides:
        isEqualTo in class Token
        Parameters:
        rightArgument - The token with which to test equality.
        Returns:
        A BooleanToken which contains the result of the test. If either this token or the argument token is a nil token, then a boolean token that contains the value false is returned.
        Throws:
        IllegalActionException - If the argument token is not of a type that can be compared with this token.