View Javadoc

1   /*
2    * Copyright (c) 2003 Peter Antman, Teknik i Media  <peter.antman@tim.se>
3    *
4    * $Id: FTPConnection.java,v 1.1.1.1 2004/05/19 12:26:42 pra Exp $
5    *
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 2 of the License, or (at your option) any later version
10   * 
11   * This library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with this library; if not, write to the Free Software
18   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 }// FTPConnection