/***
* This method is invoked by a ProtocolCommandEvent source after
* sending a protocol command to a server.
*
* @param event The ProtocolCommandEvent fired.
***/
public void protocolCommandSent(ProtocolCommandEvent event);
/***
* This method is invoked by a ProtocolCommandEvent source after
* receiving a reply from a server.
*
* @param event The ProtocolCommandEvent fired.
***/
public void protocolReplyReceived(ProtocolCommandEvent event);
}
本文的最后一个文件是ProtocolCommandEvent.java。这个文件包含了一个EventObject 类中的叫做ProtocolCommandEvent的子集。EventObject的子集用于通过从event producer到event listeners的事件数据。ProtocolCommandEvent 类增加了一个定义在EventObject中的getSource()方法,创建了creates the getMessage(), isReply(), isCommand(), getReplyCode() and getCommand()方法。这些方法只能返回给类一个只读字段,只能在构造函数中设置。
ProtocolCommandEvent.java
public class ProtocolCommandEvent extends EventObject {
** int __replyCode;
** boolean __isCommand;
** String __message, __command;
public ProtocolCommandEvent(Object source, String command, String message) {
super(source);
__replyCode = 0;
__message = message;
__isCommand = true;
__command = command;
}
public ProtocolCommandEvent(Object source, int replyCode, String message) {
super(source);
__replyCode = replyCode;
__message = message;
__isCommand = false;
__command = null;
}
public String getCommand() { return __command; }
public int getReplyCode() { return __replyCode; }
public boolean isCommand() { return __isCommand; }
public boolean isReply() { return !isCommand(); }
public String getMessage() { return __message; }
}