public class MessageDistributor extends java.lang.Object implements MessageReceiver
MessageReceiver
objects registered at this
MessageDistributor. When registering, the MessageReceiver
has
to pass a type to identify which type of messages they want to have
forwarded. Note that multiple MessageReceiver
s can be
registered to get the same type of messages as well as a
MessageReceiver
can be registered with different types of
messages, if it is capable of handling such. This enables a modeller i.e. to
get the error messages displayed on screen additional to the file being
stored on harddisk by default. This is also handy if a simulation should be
run as an Applet thus having no or restricted disk access and using multiple
scrollable windows instead.Constructor and Description |
---|
MessageDistributor()
Constructs a new messagedistributor.
|
Modifier and Type | Method and Description |
---|---|
void |
deRegister(MessageReceiver out)
De-registers the given messagereceiver from all types of Messages it was
registered at.
|
void |
deRegister(MessageReceiver out,
java.lang.Class<?> messageType)
De-registers a messagereceiver object to stop receiving messages of the
given type.
|
void |
deRegister(MessageReceiver out,
java.lang.String className)
De-registers a messagereceiver object to stop receiving messages of the
given type.
|
boolean |
isOn(java.lang.Class<?> messageType)
Checks if the current messagetype is switched on to be distributed.
|
boolean |
isRegistered(java.lang.Class<?> messageType)
Checks if the given messagetype is registered at this messagedistributor.
|
void |
receive(Message m)
Receives a message and forwards it to all messagereceiver objects
registered with the type of message sent.
|
void |
receive(Reporter r)
Receives a reporter and forwards it to all messagereceiver objects
registered with the type of reporter sent.
|
void |
register(MessageReceiver out,
java.lang.Class<?> messageType)
Registers a messagereceiver object to receive messages of the given type.
|
void |
register(MessageReceiver out,
java.lang.String className)
Registers a messagereceiver object to receive messages of the given type.
|
void |
skip(java.lang.Class<?> messageType)
Skips the transmission of the next tracenote or increases the skipCounter
by one.
|
void |
skip(java.lang.Class<?> messageType,
int skipNumber)
Skips the transmission of a number of future messages by increasing the
skipCount by the given number.
|
void |
switchOff(java.lang.Class<?> messageType)
Disables messages of the given type to be sent to the registered
receivers.
|
void |
switchOn(java.lang.Class<?> messageType)
Enables messages of the given type to be sent to the registered
receivers.
|
public MessageDistributor()
public void deRegister(MessageReceiver out)
out
- MessageReceiver : The messagereceiver to be removed from all
messages' lists of receiverspublic void deRegister(MessageReceiver out, java.lang.Class<?> messageType)
null
references) this method
simply returnsout
- MessageReceiver : The messagereceiver to be de-registeredmessageType
- java.lang.Class : The type of messages the messagereceiver
should be deregistered frompublic void deRegister(MessageReceiver out, java.lang.String className)
null
references) this method
simply returnsout
- MessageReceiver : The messagereceiver to be de-registeredclassName
- String : The type of messages the messagereceiver
should be deregistered frompublic boolean isOn(java.lang.Class<?> messageType)
true
if the type of message is
distributed false
if not or messagetype is not
registered herepublic boolean isRegistered(java.lang.Class<?> messageType)
true
if the messagetype is
registered, false
if notpublic void receive(Message m)
receive
in interface MessageReceiver
m
- Message : The message to be forwarded to all registered
MessageReceiverspublic void receive(Reporter r)
receive
in interface MessageReceiver
r
- Reporter : The reporter to be forwarded to all registered
messagereceivers.public void register(MessageReceiver out, java.lang.Class<?> messageType)
out
- MessageReceiver : The messagereceiver to be registeredmessageType
- java.lang.Class : The type of messages the messagereceiver is
registered withpublic void register(MessageReceiver out, java.lang.String className)
out
- MessageReceiver : The messagereceiver to be registeredclassName
- java.lang.String : The name of the type of messages the
messagereceiver is registered withpublic void skip(java.lang.Class<?> messageType)
public void skip(java.lang.Class<?> messageType, int skipNumber)
skipNumber
- int : The number of messages to skippublic void switchOff(java.lang.Class<?> messageType)
messageType
- Class : The type of messages to be switched offpublic void switchOn(java.lang.Class<?> messageType)
messageType
- Class : The type of messages to be switched on