public abstract class FTPFileStrategy extends Object
Constructor and Description |
---|
FTPFileStrategy() |
Modifier and Type | Method and Description |
---|---|
static FTPFileStrategy |
autoDetect()
Returns a strategy that will detect whether or not an FTP file system is Unix-like or not.
|
protected String |
fileName(Path path)
Returns a path's file name.
|
protected abstract List<FTPFile> |
getChildren(FTPClient client,
Path path,
FileSystemExceptionFactory exceptionFactory)
Returns the direct children for a path.
|
protected abstract FTPFile |
getFTPFile(FTPClient client,
Path path,
FileSystemExceptionFactory exceptionFactory)
Returns a single FTP file.
|
protected abstract FTPFile |
getLink(FTPClient client,
FTPFile ftpFile,
Path path,
FileSystemExceptionFactory exceptionFactory)
Returns an FTP file representing a link.
|
protected void |
initialize(FTPClient client)
Initializes the FTP file strategy.
|
static FTPFileStrategy |
nonUnix()
Returns a strategy for non-Unix-like FTP file systems.
|
protected String |
parentPath(Path path)
Returns a path's parent path.
|
protected String |
path(Path path)
Returns a path's full path.
|
protected void |
throwIfEmpty(FTPFile[] ftpFiles,
Path path,
FTPClient client,
FileSystemExceptionFactory exceptionFactory)
Throws a
FileSystemException if the given array of FTP files is empty. |
static FTPFileStrategy |
unix()
Returns a strategy for Unix-like FTP file systems.
|
protected void initialize(FTPClient client) throws IOException
client
- The FTP client to use for initialization.IOException
- If an I/O error occurs.protected abstract List<FTPFile> getChildren(FTPClient client, Path path, FileSystemExceptionFactory exceptionFactory) throws IOException
client
- The FTP client to use.path
- The path to return the direct children for.exceptionFactory
- The file system exception factory to use.NoSuchFileException
- If the given path does not exist.NotDirectoryException
- If the given path does not represent a directory.IOException
- If an I/O error occurs.protected abstract FTPFile getFTPFile(FTPClient client, Path path, FileSystemExceptionFactory exceptionFactory) throws IOException
client
- The FTP client to use.path
- The path to return the matching FTP file for.exceptionFactory
- The file system exception factory to use.NoSuchFileException
- If the given path does not exist.IOException
- If an I/O error occurs.protected abstract FTPFile getLink(FTPClient client, FTPFile ftpFile, Path path, FileSystemExceptionFactory exceptionFactory) throws IOException
FTPFile.getLink()
is not null
, or it can be more complex.client
- The FTP client to use.ftpFile
- The FTP file that represents the possible link.path
- The path to the FTP file.exceptionFactory
- The file system exception factory to use.null
if they represent a non-link.IOException
- If an I/O error occurs.protected final String fileName(Path path)
path
- The path to return the file name of.protected final String path(Path path)
path
- The path to return the full path of.protected final String parentPath(Path path)
path
- The path to return the parent path of.null
if the path has no parent.protected final void throwIfEmpty(FTPFile[] ftpFiles, Path path, FTPClient client, FileSystemExceptionFactory exceptionFactory) throws FileSystemException
FileSystemException
if the given array of FTP files is empty.
This method will delegate to FileSystemExceptionFactory.createGetFileException(String, int, String)
if needed.ftpFiles
- The array of FTP files to check.path
- The path that was used to retrieve the FTP files.client
- The FTP client that was used to retrieve the FTP files.exceptionFactory
- The file system exception factory to use.FileSystemException
- If the given array of FTP files is empty.public static FTPFileStrategy unix()
public static FTPFileStrategy nonUnix()
This strategy should be used for FTP file systems that do not support absolute paths to list files.
public static FTPFileStrategy autoDetect()
Copyright © 2016–2024. All rights reserved.