* @return Return true if the get() method of this receiver will
* return a token without throwing a NoTokenException. Return
* false if the current thread is not a DDEThread.
*/
public boolean hasToken() {
Workspace workspace = getContainer().workspace();
Thread thread = Thread.currentThread();
if (!(thread instanceof DDEThread)) {
return false;
}
TimeKeeper timeKeeper = ((DDEThread) thread).getTimeKeeper();
boolean sendNullTokens = false;
synchronized (_director) {
//////////////////////
// Update the ReceiverList
//////////////////////
timeKeeper.updateReceiverList(this);
/////////////////////////////////////////
// Determine if this Receiver is in Front
/////////////////////////////////////////
if (this != timeKeeper.getFirstReceiver()) {
return false;
}
//////////////////////////////////////////
// Determine if the TimeKeeper is inactive
//////////////////////////////////////////
if (timeKeeper.getNextTime().getDoubleValue() == INACTIVE) {
requestFinish();
}
///////////////////
// Check Receiver Times
///////////////////
if ((getReceiverTime().getDoubleValue() == IGNORE) && !_terminate) {
timeKeeper.removeAllIgnoreTokens();
sendNullTokens = true;
}
///////////////////////////
// Check Token Availability
///////////////////////////
if (super.hasToken() && !_terminate && !sendNullTokens) {
if (!_hasNullToken()) {
_hasTokenCache = true;
return true;
} else {
// Treat Null Tokens Normally For Feedback
if (!_hideNullTokens) {
_hasTokenCache = true;
return true;
}
// Deal With Null Tokens Separately
super.get();
sendNullTokens = true;
}
}
////////////////////////
// Perform Blocking Read
////////////////////////
if (!super.hasToken() && !_terminate && !sendNullTokens) {
_readPending = thread;
_director.threadBlocked(thread, this, DDEDirector.READ_BLOCKED);
while ((_readPending != null) && !_terminate) {
try {
workspace.wait(_director);
} catch (InterruptedException e) {
_terminate = true;
break;
}
}