public synchronized void put(Token token) {
try {
IOPort port = getContainer();
if (port == null) {
throw new InternalErrorException(
"put() requires that the port has a container");
}
Parameter priority = (Parameter) port.getAttribute("priority");
if (priority == null) {
if (port.getContainer() == null) {
throw new InternalErrorException(
"put() requires that the port '"
+ port
+ "' that contains this receiver be itself "
+ "contained");
}
priority = (Parameter) port.getContainer().getAttribute(
"priority");
}
int priorityValue = 5;
if (priority != null) {
try {
priorityValue = ((IntToken) priority.getToken()).intValue();
} catch (ClassCastException ex) {
throw new InternalErrorException(null, ex,
"priorityValue '" + priority.getToken()
+ "' must be an integer in "
+ getContainer());
}
}
getDirector()._enqueueEvent(
new TMEvent(this, token, priorityValue, -1.0));
} catch (IllegalActionException ex) {
throw new InternalErrorException(null, ex, null);
}
}