⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.net

Class ProtocolCommandSupport

java.lang.Object
|
+--org.apache.commons.net.ProtocolCommandSupport

All Implemented Interfaces:
Serializable


public class ProtocolCommandSupport
extends java.lang.Object
implements Serializable

ProtocolCommandSupport 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.

Author:
Daniel F. Savarese
See Also:
ProtocolCommandEvent
ProtocolCommandListener

Constructor Summary

ProtocolCommandSupport(Object source)

Creates a ProtocolCommandSupport instant using the indicated source as the source of fired ProtocolCommandEvents.

Method Summary

void

addProtocolCommandListener(ProtocolCommandListener listener)

Adds a ProtocolCommandListener.

void

fireCommandSent(String command, String message)

Fires a ProtocolCommandEvent signalling the sending of a command to all registered listeners, invoking their protocolCommandSent() methods.

void

fireReplyReceived(int replyCode, String message)

Fires a ProtocolCommandEvent signalling the reception of a command reply to all registered listeners, invoking their protocolReplyReceived() methods.

int

getListenerCount()

Returns the number of ProtocolCommandListeners currently registered.

void

removeProtocolCommandListener(ProtocolCommandListener listener)

Removes a ProtocolCommandListener.

Constructor Details

ProtocolCommandSupport

public ProtocolCommandSupport(Object source)

Creates a ProtocolCommandSupport instant using the indicated source as the source of fired ProtocolCommandEvents.

Parameters:
source - The source to use for all generated ProtocolCommandEvents.

Method Details

addProtocolCommandListener

public void addProtocolCommandListener(ProtocolCommandListener listener)

Adds a ProtocolCommandListener.

Parameters:
listener - The ProtocolCommandListener to add.

fireCommandSent

public void fireCommandSent(String command, String message)

Fires a ProtocolCommandEvent signalling the sending of a command to all registered listeners, invoking their protocolCommandSent() methods.

Parameters:
command - The string representation of the command type sent, not including the arguments (e.g., "STAT" or "GET").
message - The entire command string verbatim as sent to the server, including all arguments.

fireReplyReceived

public void fireReplyReceived(int replyCode, String message)

Fires a ProtocolCommandEvent signalling the reception of a command reply to all registered listeners, invoking their protocolReplyReceived() methods.

Parameters:
replyCode - The integer code indicating the natureof the reply.
message - The entire reply as received from the server.

getListenerCount

public int getListenerCount()

Returns the number of ProtocolCommandListeners currently registered.

Returns:
The number of ProtocolCommandListeners currently registered.

removeProtocolCommandListener

public void removeProtocolCommandListener(ProtocolCommandListener listener)

Removes a ProtocolCommandListener.

Parameters:
listener - The ProtocolCommandListener to remove.