01: /*
02: * Copyright 2001-2005 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package examples;
17:
18: import java.io.PrintWriter;
19: import org.apache.commons.net.ProtocolCommandEvent;
20: import org.apache.commons.net.ProtocolCommandListener;
21:
22: /***
23: * This is a support class for some of the example programs. It is
24: * a sample implementation of the ProtocolCommandListener interface
25: * which just prints out to a specified stream all command/reply traffic.
26: * <p>
27: ***/
28:
29: public class PrintCommandListener implements ProtocolCommandListener {
30: private PrintWriter __writer;
31:
32: public PrintCommandListener(PrintWriter writer) {
33: __writer = writer;
34: }
35:
36: public void protocolCommandSent(ProtocolCommandEvent event) {
37: __writer.print(event.getMessage());
38: __writer.flush();
39: }
40:
41: public void protocolReplyReceived(ProtocolCommandEvent event) {
42: __writer.print(event.getMessage());
43: __writer.flush();
44: }
45: }
|