Package org.apache.commons.net
Class ProtocolCommandSupport
java.lang.Object
org.apache.commons.net.ProtocolCommandSupport
- All Implemented Interfaces:
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.
- See Also:
-
Constructor Summary
ConstructorDescriptionProtocolCommandSupport
(Object source) Creates a ProtocolCommandSupport instance using the indicated source as the source of ProtocolCommandEvents. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a ProtocolCommandListener.void
fireCommandSent
(String command, String message) Fires a ProtocolCommandEvent signalling the sending of a command to all registered listeners, invoking theirprotocolCommandSent()
methods.void
fireReplyReceived
(int replyCode, String message) Fires a ProtocolCommandEvent signalling the reception of a command reply to all registered listeners, invoking theirprotocolReplyReceived()
methods.int
Returns the number of ProtocolCommandListeners currently registered.void
Removes a ProtocolCommandListener.
-
Constructor Details
-
ProtocolCommandSupport
Creates a ProtocolCommandSupport instance using the indicated source as the source of ProtocolCommandEvents.- Parameters:
source
- The source to use for all generated ProtocolCommandEvents.
-
-
Method Details
-
addProtocolCommandListener
Adds a ProtocolCommandListener.- Parameters:
listener
- The ProtocolCommandListener to add.
-
fireCommandSent
Fires a ProtocolCommandEvent signalling the sending of a command to all registered listeners, invoking theirprotocolCommandSent()
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
Fires a ProtocolCommandEvent signalling the reception of a command reply to all registered listeners, invoking theirprotocolReplyReceived()
methods.- Parameters:
replyCode
- The integer code indicating the natureof the reply. This will be the protocol integer value for protocols that use integer reply codes, or the reply class constant corresponding to the reply for protocols like POP3 that use strings like OK rather than integer codes (i.e., POP3Repy.OK).message
- The entire reply as received from the server.
-
getListenerCount
Returns the number of ProtocolCommandListeners currently registered.- Returns:
- The number of ProtocolCommandListeners currently registered.
-
removeProtocolCommandListener
Removes a ProtocolCommandListener.- Parameters:
listener
- The ProtocolCommandListener to remove.
-