com.enterprisedt.net.ftp
Class RecursiveOperations

java.lang.Object
  extended by com.enterprisedt.net.ftp.RecursiveOperations

public class RecursiveOperations
extends java.lang.Object

Performs various recursive FTP operations. Some operations permit a wildcard string to be supplied for matching filenames (directories are not matched against the wildcard). The syntax used is '?' for single chars and '*' for multiple chars, e.g. 'asdf??df*abc' would match 'asdfxydfdsfsjfkj33abc'. On Windows clients, case is ignored.

Note that if there are a large number of files to be transferred, the client or server may run out of sockets, as a new socket is created for each data transfer and each directory listing. TCP's TIME_WAIT means that sockets are not reclaimed immediately. If sleeping is enabled via setSleepEnabled(true), then Thread.sleep() is called after n transfers, where n is set by setCountBeforeSleep(n). The time spent asleep is set via setSleepTime().

Version:
$Revision: 1.23 $
Author:
Bruce Blackshaw

Field Summary
static java.lang.String cvsId
          Revision control id
 
Constructor Summary
RecursiveOperations()
           
 
Method Summary
 void delete(FTPClientInterface ftp, java.lang.String remoteDir)
          Delete this entire remote directory and its contents, recursively going through the remote directory name supplied
 void deleteFiles(FTPClientInterface ftp, java.io.FileFilter filter, boolean recurse)
          Delete all the files in the current directory (and its subdirectories if indicated) that match the supplied filter, recursively going through the remote directories.
 void deleteFiles(FTPClientInterface ftp, java.lang.String remoteDir, java.io.FileFilter filter)
          Delete all the files in this directory (and its subdirectories) that match the supplied filter, recursively going through the remote directories.
 void deleteFiles(FTPClientInterface ftp, java.lang.String remoteDir, java.io.FileFilter filter, boolean recurse)
          Delete all the files in this directory (and its subdirectories if recurse is true) that match the supplied filter, recursively going through the remote directories.
 void deleteFiles(FTPClientInterface ftp, java.lang.String remoteDir, java.lang.String wildcard)
          Delete all the files in this directory (and its subdirectories) that match the supplied wildcard, recursively going through the remote directories.
 void deleteFilesCurrentDir(FTPClientInterface ftp, java.io.FileFilter filter)
          Delete all the files in this directory (not subdirectories) that match the supplied filter.
 FTPFile[] dirDetails(FTPClientInterface ftp, java.lang.String remoteDir)
          List this entire remote directory and its contents, including children.
 void get(FTPClientInterface ftp, java.lang.String localDir, java.lang.String remoteDir)
          Gets this entire remote directory and its contents, recursively going through the remote directory name supplied.
 void get(FTPClientInterface ftp, java.lang.String localDir, java.lang.String remoteDir, java.io.FileFilter filter)
          Gets this entire remote directory and its contents, recursively going through the remote directory name supplied.
 void get(FTPClientInterface ftp, java.lang.String localDir, java.lang.String remoteDir, java.io.FileFilter filter, boolean recurse)
          Gets this entire remote directory and its contents, recursively (if recurse is true) going through the remote directory name supplied.
 void get(FTPClientInterface ftp, java.lang.String localDir, java.lang.String remoteDir, java.lang.String wildcard)
          Gets this entire remote directory and its contents, recursively going through the remote directory name supplied.
 int getCountBeforeSleep()
          Get the number of transfers set before sleeping
 void getFilesFromCurrentDir(FTPClientInterface ftp, java.lang.String localDir, java.io.FileFilter filter)
          Gets all files matching the supplied filter from current remote directory into supplied local dir.
 int getSleepTime()
          Get the number of seconds spent asleep
 boolean isSleepEnabled()
          Is sleeping enabled?
 void put(FTPClientInterface ftp, java.lang.String localDir, java.lang.String remoteDir)
          Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute.
 void put(FTPClientInterface ftp, java.lang.String localDir, java.lang.String remoteDir, java.io.FileFilter filter)
          Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute.
 void put(FTPClientInterface ftp, java.lang.String localDir, java.lang.String remoteDir, java.io.FileFilter filter, boolean recurse)
          Puts this entire directory and its contents.
 void put(FTPClientInterface ftp, java.lang.String localDir, java.lang.String remoteDir, java.lang.String wildcard)
          Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute.
 void putFilesIntoCurrentDir(FTPClientInterface ftp, java.lang.String localDir, java.io.FileFilter filter)
          Puts all files from supplied local dir matching the supplied filter into the current remote directory.
 void setCountBeforeSleep(int countBeforeSleep)
          Set the number of transfers required before sleeping
 void setSleepEnabled(boolean sleepEnabled)
          Set sleeping enabled to be on or off
 void setSleepTime(int sleepTime)
          Set the time spent asleep
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cvsId

public static java.lang.String cvsId
Revision control id

Constructor Detail

RecursiveOperations

public RecursiveOperations()
Method Detail

getCountBeforeSleep

public int getCountBeforeSleep()
Get the number of transfers set before sleeping

Returns:
integer

setCountBeforeSleep

public void setCountBeforeSleep(int countBeforeSleep)
Set the number of transfers required before sleeping

Parameters:
countBeforeSleep - maximum transfer count

isSleepEnabled

public boolean isSleepEnabled()
Is sleeping enabled?

Returns:
true if enabled

setSleepEnabled

public void setSleepEnabled(boolean sleepEnabled)
Set sleeping enabled to be on or off

Parameters:
sleepEnabled - if true, sleeping is enabled, otherwise it is switched off

getSleepTime

public int getSleepTime()
Get the number of seconds spent asleep

Returns:
integer

setSleepTime

public void setSleepTime(int sleepTime)
Set the time spent asleep

Parameters:
sleepTime - sleep time in seconds

dirDetails

public FTPFile[] dirDetails(FTPClientInterface ftp,
                            java.lang.String remoteDir)
                     throws java.io.IOException,
                            FTPException,
                            java.text.ParseException
List this entire remote directory and its contents, including children.

Parameters:
ftp - the FTP client reference
remoteDir - name of remote directory
Throws:
java.io.IOException
FTPException
java.text.ParseException

delete

public void delete(FTPClientInterface ftp,
                   java.lang.String remoteDir)
            throws java.io.IOException,
                   FTPException,
                   java.text.ParseException
Delete this entire remote directory and its contents, recursively going through the remote directory name supplied

Parameters:
ftp - the FTP client reference
remoteDir - name of remote directory
Throws:
java.io.IOException
FTPException
java.text.ParseException

deleteFilesCurrentDir

public void deleteFilesCurrentDir(FTPClientInterface ftp,
                                  java.io.FileFilter filter)
                           throws java.io.IOException,
                                  FTPException,
                                  java.text.ParseException
Delete all the files in this directory (not subdirectories) that match the supplied filter. Only files matching the filter are deleted. On Windows clients, case is ignored.

Parameters:
ftp - the FTP client reference
filter - filename filter
Throws:
java.io.IOException
FTPException
java.text.ParseException

deleteFiles

public void deleteFiles(FTPClientInterface ftp,
                        java.lang.String remoteDir,
                        java.io.FileFilter filter,
                        boolean recurse)
                 throws java.io.IOException,
                        FTPException,
                        java.text.ParseException
Delete all the files in this directory (and its subdirectories if recurse is true) that match the supplied filter, recursively going through the remote directories. No directories are deleted. Only files matching the filter are deleted. On Windows clients, case is ignored.

Parameters:
ftp - the FTP client reference
remoteDir - name of remote directory
filter - filename filter
recurse - true if recursing through subdirectories
Throws:
java.io.IOException
FTPException
java.text.ParseException

deleteFiles

public void deleteFiles(FTPClientInterface ftp,
                        java.io.FileFilter filter,
                        boolean recurse)
                 throws java.io.IOException,
                        FTPException,
                        java.text.ParseException
Delete all the files in the current directory (and its subdirectories if indicated) that match the supplied filter, recursively going through the remote directories. No directories are deleted. Only files matching the filter are deleted. On Windows clients, case is ignored.

Parameters:
ftp - the FTP client reference
filter - filename filter
recurse - true if recursing through subdirectories
Throws:
java.io.IOException
FTPException
java.text.ParseException

deleteFiles

public void deleteFiles(FTPClientInterface ftp,
                        java.lang.String remoteDir,
                        java.io.FileFilter filter)
                 throws java.io.IOException,
                        FTPException,
                        java.text.ParseException
Delete all the files in this directory (and its subdirectories) that match the supplied filter, recursively going through the remote directories. No directories are deleted. Only files matching the filter are deleted. On Windows clients, case is ignored.

Parameters:
ftp - the FTP client reference
remoteDir - name of remote directory
filter - filename filter
Throws:
java.io.IOException
FTPException
java.text.ParseException

deleteFiles

public void deleteFiles(FTPClientInterface ftp,
                        java.lang.String remoteDir,
                        java.lang.String wildcard)
                 throws java.io.IOException,
                        FTPException,
                        java.text.ParseException
Delete all the files in this directory (and its subdirectories) that match the supplied wildcard, recursively going through the remote directories. No directories are deleted. Only files matching the wildcard are fetched. On Windows clients, case is ignored.

Parameters:
ftp - the FTP client reference
remoteDir - name of remote directory
wildcard - wildcard for filename matching
Throws:
java.io.IOException
FTPException
java.text.ParseException

getFilesFromCurrentDir

public void getFilesFromCurrentDir(FTPClientInterface ftp,
                                   java.lang.String localDir,
                                   java.io.FileFilter filter)
                            throws java.io.IOException,
                                   FTPException,
                                   java.text.ParseException
Gets all files matching the supplied filter from current remote directory into supplied local dir. No directories are retrieved.

Parameters:
ftp - the FTP client reference
localDir - name of local directory to get files into
filter - filename filter
Throws:
java.io.IOException
FTPException
java.text.ParseException

get

public void get(FTPClientInterface ftp,
                java.lang.String localDir,
                java.lang.String remoteDir)
         throws java.io.IOException,
                FTPException,
                java.text.ParseException
Gets this entire remote directory and its contents, recursively going through the remote directory name supplied. Gets the directory into the current local directory, into a directory with supplied localDir name

Parameters:
ftp - the FTP client reference
localDir - name of local directory we are transferring into
remoteDir - name of remote directory
Throws:
java.io.IOException
FTPException
java.text.ParseException

get

public void get(FTPClientInterface ftp,
                java.lang.String localDir,
                java.lang.String remoteDir,
                java.io.FileFilter filter)
         throws java.io.IOException,
                FTPException,
                java.text.ParseException
Gets this entire remote directory and its contents, recursively going through the remote directory name supplied. Gets the directory into the current local directory, into a directory with supplied localDir name. Only files matching the filter are fetched. On Windows clients, case is ignored.

Parameters:
ftp - the FTP client reference
localDir - name of local directory we are transferring into
remoteDir - name of remote directory
filter - filename filter
Throws:
java.io.IOException
FTPException
java.text.ParseException

get

public void get(FTPClientInterface ftp,
                java.lang.String localDir,
                java.lang.String remoteDir,
                java.lang.String wildcard)
         throws java.io.IOException,
                FTPException,
                java.text.ParseException
Gets this entire remote directory and its contents, recursively going through the remote directory name supplied. Gets the directory into the current local directory, into a directory with supplied localDir name. Only files matching the wildcard are fetched. On Windows clients, case is ignored.

Parameters:
ftp - the FTP client reference
localDir - name of local directory we are transferring into
remoteDir - name of remote directory
wildcard - wildcard for filename matching
Throws:
java.io.IOException
FTPException
java.text.ParseException

get

public void get(FTPClientInterface ftp,
                java.lang.String localDir,
                java.lang.String remoteDir,
                java.io.FileFilter filter,
                boolean recurse)
         throws java.io.IOException,
                FTPException,
                java.text.ParseException
Gets this entire remote directory and its contents, recursively (if recurse is true) going through the remote directory name supplied. Gets the directory into the current local directory, into a directory with supplied localDir name. Only files matching the filter are fetched. On Windows clients, case is ignored.

Parameters:
ftp - the FTP client reference
localDir - name of local directory we are transferring into
remoteDir - name of remote directory
filter - filename filter
recurse - if true recurse through subdirectories
Throws:
java.io.IOException
FTPException
java.text.ParseException

putFilesIntoCurrentDir

public void putFilesIntoCurrentDir(FTPClientInterface ftp,
                                   java.lang.String localDir,
                                   java.io.FileFilter filter)
                            throws FTPException,
                                   java.io.IOException
Puts all files from supplied local dir matching the supplied filter into the current remote directory. No directories are put.

Parameters:
ftp - the FTP client reference
localDir - name of local directory
Throws:
FTPException
java.io.IOException

put

public void put(FTPClientInterface ftp,
                java.lang.String localDir,
                java.lang.String remoteDir)
         throws FTPException,
                java.io.IOException
Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name.

Parameters:
ftp - the FTP client reference
localDir - name of local directory
remoteDir - name of remote directory
Throws:
FTPException
java.io.IOException

put

public void put(FTPClientInterface ftp,
                java.lang.String localDir,
                java.lang.String remoteDir,
                java.io.FileFilter filter)
         throws FTPException,
                java.io.IOException
Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name. Only files matching the filter are fetched. On Windows clients, case is ignored.

Parameters:
ftp - the FTP client reference
localDir - name of local directory
remoteDir - name of remote directory
filter - filename filter
Throws:
FTPException
java.io.IOException

put

public void put(FTPClientInterface ftp,
                java.lang.String localDir,
                java.lang.String remoteDir,
                java.lang.String wildcard)
         throws FTPException,
                java.io.IOException
Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name. Only files matching the wildcard are fetched. On Windows clients, case is ignored.

Parameters:
ftp - the FTP client reference
localDir - name of local directory
remoteDir - name of remote directory
wildcard - wildcard for filename matching
Throws:
FTPException
java.io.IOException

put

public void put(FTPClientInterface ftp,
                java.lang.String localDir,
                java.lang.String remoteDir,
                java.io.FileFilter filter,
                boolean recurse)
         throws FTPException,
                java.io.IOException
Puts this entire directory and its contents. If recurse is true, it recursively goes through the local directory supplied (which can be relative or absolute. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name. Only files matching the filter are fetched. On Windows clients, case is ignored.

Parameters:
ftp - the FTP client reference
localDir - name of local directory
remoteDir - name of remote directory, or null if the current remote directory
filter - filename filter
Throws:
FTPException
java.io.IOException


Copyright © 2001-2006 Enterprise Distributed Technologies Ltd. All Rights Reserved.