Package org.apache.commons.net
Class ProtocolCommandSupport
- java.lang.Object
-
- org.apache.commons.net.ProtocolCommandSupport
-
- All Implemented Interfaces:
java.io.Serializable
public class ProtocolCommandSupport extends java.lang.Object implements java.io.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.
-
-
Field Summary
Fields Modifier and Type Field Description private ListenerList<ProtocolCommandListener>listenersThe ProtocolCommandListener.private static longserialVersionUIDSerialization is unnecessary for this class.private java.lang.ObjectsourceThe source to use for all generated ProtocolCommandEvents.
-
Constructor Summary
Constructors Constructor Description ProtocolCommandSupport(java.lang.Object source)Creates a ProtocolCommandSupport instance using the indicated source as the source of ProtocolCommandEvents.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProtocolCommandListener(ProtocolCommandListener listener)Adds a ProtocolCommandListener.voidfireCommandSent(java.lang.String command, java.lang.String message)Fires a ProtocolCommandEvent signaling the sending of a command to all registered listeners, invoking theirprotocolCommandSent()methods.voidfireReplyReceived(int replyCode, java.lang.String message)Fires a ProtocolCommandEvent signaling the reception of a command reply to all registered listeners, invoking theirprotocolReplyReceived()methods.intgetListenerCount()Gets the number of ProtocolCommandListeners currently registered.private voidreadObject(java.io.ObjectInputStream ignored)Throws UnsupportedOperationException.voidremoveProtocolCommandListener(ProtocolCommandListener listener)Removes a ProtocolCommandListener.private voidwriteObject(java.io.ObjectOutputStream ignored)Always throwsUnsupportedOperationException.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Serialization is unnecessary for this class. Reject attempts to do so until such time as the Serializable attribute can be dropped.- See Also:
- Constant Field Values
-
source
private final java.lang.Object source
The source to use for all generated ProtocolCommandEvents.
-
listeners
private final ListenerList<ProtocolCommandListener> listeners
The ProtocolCommandListener.
-
-
Method Detail
-
addProtocolCommandListener
public void addProtocolCommandListener(ProtocolCommandListener listener)
Adds a ProtocolCommandListener.- Parameters:
listener- The ProtocolCommandListener to add.
-
fireCommandSent
public void fireCommandSent(java.lang.String command, java.lang.String message)Fires a ProtocolCommandEvent signaling 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
public void fireReplyReceived(int replyCode, java.lang.String message)Fires a ProtocolCommandEvent signaling the reception of a command reply to all registered listeners, invoking theirprotocolReplyReceived()methods.- Parameters:
replyCode- The integer code indicating the nature of 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
public int getListenerCount()
Gets the number of ProtocolCommandListeners currently registered.- Returns:
- The number of ProtocolCommandListeners currently registered.
-
readObject
private void readObject(java.io.ObjectInputStream ignored)
Throws UnsupportedOperationException.- Parameters:
ignored- Ignored.
-
removeProtocolCommandListener
public void removeProtocolCommandListener(ProtocolCommandListener listener)
Removes a ProtocolCommandListener.- Parameters:
listener- The ProtocolCommandListener to remove.
-
writeObject
private void writeObject(java.io.ObjectOutputStream ignored)
Always throwsUnsupportedOperationException.- Parameters:
ignored- ignored.- Throws:
java.lang.UnsupportedOperationException- Always thrown.
-
-