Class BluetoothResponseToken<T>
- java.lang.Object
-
- ptolemy.data.Token
-
- ptolemy.domains.wireless.lib.bluetooth.BluetoothToken
-
- ptolemy.domains.wireless.lib.bluetooth.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 Summary
Constructors Constructor Description BluetoothResponseToken(BluetoothResponse response, java.lang.String deviceIdentifier, java.lang.String sourceIdentifier, T data)
Construct a BluetoothResposeToken.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
getData()
Get the data stored within this token.java.lang.String
getDeviceIdentifier()
Get the name of the target device associated with this token.BluetoothResponse
getResponse()
Get the BluetoothResponse enum element associated with this token.java.lang.String
getSourceIdentifier()
Get the name of the source device associated with this token.BooleanToken
isEqualTo(Token rightArgument)
Test for equality of the values of this Token and the argument Token.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.-
Methods inherited from class ptolemy.domains.wireless.lib.bluetooth.BluetoothToken
add, addReverse, divide, divideReverse, isCloseTo, modulo, moduloReverse, multiply, multiplyReverse, pow, subtract, subtractReverse
-
Methods inherited from class ptolemy.data.Token
getType, isCloseTo, isNil, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, one, zero, zeroReturnType
-
-
-
-
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 isToken.NIL
then return "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 classToken
- 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.
-
-