1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.backsource.adaptor.ftp;
21 import java.io.InputStream;
22 import java.util.List;
23
24 /***
25 * Interface for an FTPConnection received from a FTPConnectionFactory.
26 *
27 * <p>A FTPConnection will be in a logged in state when returned from the
28 * factory. There is however no guarantee that it will stay in that mode
29 * due to FTP server timeout or socket timeout. A connection that is no
30 longer in alive mode should be closed and a new connection must be retrived from the factory.</p>
31 <p>See {@link FTPConnectionFactory} for some examples.</p>
32
33 *
34 * @author <a href="mailto:pra@tim.se">Peter Antman</a>
35 * @version $Revision: 1.1.1.1 $
36 */
37
38 public interface FTPConnection {
39 /***
40 * Close the connection, effectively leaving it back to the factory.
41 */
42 public void close();
43
44 /***
45 * Set mode of connection, false means ascii mode.
46 */
47 public void setBinaryMode(boolean binaryMode) throws FTPException;
48
49 /***
50 * Set passive mode.
51 */
52 public void setPassiveMode(boolean passiveMode) throws FTPException;
53
54 /***
55 * Check if connection is alive.
56 *
57 * <p>This will also work as a ping, and may thefore be called from a ping thtread to keep the connection alive.
58 */
59 public boolean isAlive();
60
61 /***
62 * List files in dir url or if single file list that file, to list
63 * files in the current directory use a . as url.
64 * @return a list of {@link FTPFile}s.
65 */
66 public List list(String url) throws FTPException;
67
68 /***
69 * Get the specifyed file from the server.
70 *
71 * <p>The input will be cached locally, and it is the callers responisbility
72 * to close the stream when used.
73 */
74 public InputStream get(String url) throws FTPException;
75
76 /***
77 * Put stream on server in file named by url, the url may denote a file with a directory path.
78 *
79 * <p>It is the resonibility of the caller to close the stream when
80 * the method return.</p>
81 */
82 public void put(String url, InputStream localStream) throws FTPException;
83
84 /***
85 * Delete specifyed file, pathname may contains directory path.
86 */
87 public void deleteFile(String pathname) throws FTPException;
88
89 /***
90 * Create a directory specifyed by pathname.
91 */
92 public void mkdir(String pathname) throws FTPException;
93
94 /***
95 * Get the name of the working directory.
96 */
97 public String getWorkingDirectory() throws FTPException;
98
99 /***
100 * Change dir.
101 */
102 public void cd(String dir) throws FTPException;
103
104
105
106 }