ProtocolCommandSupportpublic class ProtocolCommandSupport extends Object implements SerializableProtocolCommandSupport is a convenience class for managing a list of
ProtocolCommandListeners and firing ProtocolCommandEvents. You can
simply delegate ProtocolCommandEvent firing and listener
registering/unregistering tasks to this class.
|
Fields Summary |
---|
private Object | __source | private org.apache.commons.net.util.ListenerList | __listeners |
Constructors Summary |
---|
public ProtocolCommandSupport(Object source)Creates a ProtocolCommandSupport instant using the indicated source
as the source of fired ProtocolCommandEvents.
__listeners = new ListenerList();
__source = source;
|
Methods Summary |
---|
public void | addProtocolCommandListener(ProtocolCommandListener listener)Adds a ProtocolCommandListener.
__listeners.addListener(listener);
| public void | fireCommandSent(java.lang.String command, java.lang.String message)Fires a ProtocolCommandEvent signalling the sending of a command to all
registered listeners, invoking their
{@link org.apache.commons.net.ProtocolCommandListener#protocolCommandSent protocolCommandSent() }
methods.
Enumeration en;
ProtocolCommandEvent event;
ProtocolCommandListener listener;
en = __listeners.getListeners();
event = new ProtocolCommandEvent(__source, command, message);
while (en.hasMoreElements())
{
listener = (ProtocolCommandListener)en.nextElement();
listener.protocolCommandSent(event);
}
| public void | fireReplyReceived(int replyCode, java.lang.String message)Fires a ProtocolCommandEvent signalling the reception of a command reply
to all registered listeners, invoking their
{@link org.apache.commons.net.ProtocolCommandListener#protocolReplyReceived protocolReplyReceived() }
methods.
Enumeration en;
ProtocolCommandEvent event;
ProtocolCommandListener listener;
en = __listeners.getListeners();
event = new ProtocolCommandEvent(__source, replyCode, message);
while (en.hasMoreElements())
{
listener = (ProtocolCommandListener)en.nextElement();
listener.protocolReplyReceived(event);
}
| public int | getListenerCount()Returns the number of ProtocolCommandListeners currently registered.
return __listeners.getListenerCount();
| public void | removeProtocolCommandListener(ProtocolCommandListener listener)Removes a ProtocolCommandListener.
__listeners.removeListener(listener);
|
|