org.backsource.adaptor.ftp
Class NetFTPConnection

java.lang.Object
  extended byorg.backsource.adaptor.ftp.NetFTPConnection
All Implemented Interfaces:
FTPConnection

public class NetFTPConnection
extends java.lang.Object
implements FTPConnection

An FTP Connection based on the jakarta commont-net-ftp lib.

It is important to know that a close() on the connections just returns the connection to the factory; and do not close the real connection.

Version:
$Revision: 1.1.1.1 $
Author:
Peter Antman

Constructor Summary
protected NetFTPConnection(FTPConnectionFactory factory)
           
 
Method Summary
 void cd(java.lang.String dir)
          Change dir.
 void close()
          Close the connection, effectively leaving it back to the factory.
protected  void connect()
           
 void deleteFile(java.lang.String url)
          Delete specifyed file, pathname may contains directory path.
 java.io.InputStream get(java.lang.String url)
          Get the specifyed file from the server.
 java.lang.String getWorkingDirectory()
          Get the name of the working directory.
protected  void internalClose()
           
 boolean isAlive()
          Check if connection is alive.
 java.util.List list(java.lang.String url)
          List files in dir url or if single file list that file, to list files in the current directory use a .
 void mkdir(java.lang.String url)
          Create a directory specifyed by pathname.
 void put(java.lang.String url, java.io.InputStream localStream)
          Put stream on server in file named by url, the url may denote a file with a directory path.
 void setBinaryMode(boolean binaryMode)
          Set mode of connection, false means ascii mode.
 void setPassiveMode(boolean passiveMode)
          Set passive mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetFTPConnection

protected NetFTPConnection(FTPConnectionFactory factory)
Method Detail

connect

protected void connect()
                throws FTPException
Throws:
FTPException

internalClose

protected void internalClose()

close

public void close()
Description copied from interface: FTPConnection
Close the connection, effectively leaving it back to the factory.

Specified by:
close in interface FTPConnection

setBinaryMode

public void setBinaryMode(boolean binaryMode)
                   throws FTPException
Description copied from interface: FTPConnection
Set mode of connection, false means ascii mode.

Specified by:
setBinaryMode in interface FTPConnection
Throws:
FTPException

setPassiveMode

public void setPassiveMode(boolean passiveMode)
                    throws FTPException
Description copied from interface: FTPConnection
Set passive mode.

Specified by:
setPassiveMode in interface FTPConnection
Throws:
FTPException

isAlive

public boolean isAlive()
Description copied from interface: FTPConnection
Check if connection is alive.

This will also work as a ping, and may thefore be called from a ping thtread to keep the connection alive.

Specified by:
isAlive in interface FTPConnection

list

public java.util.List list(java.lang.String url)
                    throws FTPException
Description copied from interface: FTPConnection
List files in dir url or if single file list that file, to list files in the current directory use a . as url.

Specified by:
list in interface FTPConnection
Returns:
a list of FTPFiles.
Throws:
FTPException

get

public java.io.InputStream get(java.lang.String url)
                        throws FTPException
Description copied from interface: FTPConnection
Get the specifyed file from the server.

The input will be cached locally, and it is the callers responisbility to close the stream when used.

Specified by:
get in interface FTPConnection
Throws:
FTPException

put

public void put(java.lang.String url,
                java.io.InputStream localStream)
         throws FTPException
Description copied from interface: FTPConnection
Put stream on server in file named by url, the url may denote a file with a directory path.

It is the resonibility of the caller to close the stream when the method return.

Specified by:
put in interface FTPConnection
Throws:
FTPException

deleteFile

public void deleteFile(java.lang.String url)
                throws FTPException
Description copied from interface: FTPConnection
Delete specifyed file, pathname may contains directory path.

Specified by:
deleteFile in interface FTPConnection
Throws:
FTPException

mkdir

public void mkdir(java.lang.String url)
           throws FTPException
Description copied from interface: FTPConnection
Create a directory specifyed by pathname.

Specified by:
mkdir in interface FTPConnection
Throws:
FTPException

getWorkingDirectory

public java.lang.String getWorkingDirectory()
                                     throws FTPException
Description copied from interface: FTPConnection
Get the name of the working directory.

Specified by:
getWorkingDirectory in interface FTPConnection
Throws:
FTPException

cd

public void cd(java.lang.String dir)
        throws FTPException
Description copied from interface: FTPConnection
Change dir.

Specified by:
cd in interface FTPConnection
Throws:
FTPException


Copyright © 2003-2004 Backsource. All Rights Reserved.