KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > coldcore > coloradoftp > command > Command


1 package com.coldcore.coloradoftp.command;
2
3 import com.coldcore.coloradoftp.connection.ControlConnection;
4
5 /**
6  * User command.
7  *
8  * This class is executed by a command processor and returns a reply which
9  * if then send back to user.
10  *
11  * In general there should be a separate implementation for every FTP command,
12  * so every implementation knows how to handle one (and only one) FTP command.
13  * This way commands can be easily replaced later.
14  *
15  * Control connection can enter an INTERRUPT state. In INTERRUPT state user must
16  * wait for a server reply and is not allowed to send anything in but the INTERRUPT
17  * commands. As a result, there are two types of FTP commands: one will be processed
18  * during the INTERRUPT state and the other will be dropped when a control connection
19  * is in that state.
20  *
21  * Some FTP commands put control connection into the INTERRUPT state which is then
22  * cleared when the connection sends a reply. Such reply must refer to a command which
23  * is allowed to clear the state or does not have a reference to a command.
24  *
25  * There is a certain set of commands that must be processed during the INTERRUPT state:
26  * ABOR, QUIT and STAT.
27  * And usually only one command is allowed to clear that state: ABOR.
28  * The rest of FTP commands should not bother with INTERRUPT state.
29  *
30  *
31  * ColoradoFTP - The Open Source FTP Server (http://cftp.coldcore.com)
32  */

33 public interface Command {
34
35   /** Test if this is command must be processed while a connection is in the INTERRUPT state
36    * @return TRUE is it can be, FALSE otherwise
37    */

38   public boolean processInInterruptState();
39
40
41   /** Test if reply to this command must clear INTERRUPT state of a connection
42    * @return TRUE is it can, FALSE otherwise
43    */

44   public boolean canClearInterruptState();
45
46
47   /** Get name of the command
48    * @return Command name
49    */

50   public String JavaDoc getName();
51
52
53   /** Set name of the command
54    * @param name Command name
55    */

56   public void setName(String JavaDoc name);
57
58
59   /** Get parameter of the command
60    * @return Command parameter
61    */

62   public String JavaDoc getParameter();
63
64
65   /** Set parameter of the command
66    * @param parameter Command parameter
67    */

68   public void setParameter(String JavaDoc parameter);
69
70
71   /** Execute the command
72    * @return Reply to the command
73    */

74   public Reply execute();
75
76
77   /** Execute the command as part of the parent command (e.g. FEAT/HELP/OPTS)
78    * @param parent Parent command
79    * @return Reply to the command or NULL to allow the parent to provide the default reply
80    */

81   public Reply executeOnParent(Command parent);
82
83
84   /** Set control connection that submitted this command
85    * @param connection Connection
86    */

87   public void setConnection(ControlConnection connection);
88
89
90   /** Get control connection that submitted this command
91    * @return Connection
92    */

93   public ControlConnection getConnection();
94 }
95
Popular Tags