de.unkrig.commons.net.ftp.ftplett
Class FileFtplett

java.lang.Object
  extended by de.unkrig.commons.net.ftp.ftplett.FileFtplett
All Implemented Interfaces:
Ftplett

public class FileFtplett
extends java.lang.Object
implements Ftplett

An implementation of Ftplett that is based on a file directory tree.


Constructor Summary
FileFtplett(java.io.File rootDirectory)
           
 
Method Summary
 boolean changeWorkingDirectory(java.lang.String directoryName)
           
 boolean delete(java.lang.String resourceName)
           
 java.util.Date getModificationTime(java.lang.String resourceName)
           
 java.lang.String getWorkingDirectory()
           
 boolean list(java.lang.String name, ConsumerWhichThrows<java.lang.String,java.io.IOException> out)
           
 boolean nameList(java.lang.String name, ConsumerWhichThrows<java.lang.String,java.io.IOException> out)
           
 boolean rename(java.lang.String from, java.lang.String to)
           
 java.io.InputStream retrieve(java.lang.String fileName)
           
 java.io.OutputStream store(java.lang.String fileName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileFtplett

public FileFtplett(java.io.File rootDirectory)
            throws java.io.IOException
Throws:
java.io.IOException
Method Detail

changeWorkingDirectory

public boolean changeWorkingDirectory(@Nullable
                                      java.lang.String directoryName)
                               throws java.io.IOException
Specified by:
changeWorkingDirectory in interface Ftplett
Parameters:
directoryName - null means change to some 'root' or 'home' directory
Returns:
Whether the working directory could be changed to the given directory.
Throws:
java.io.IOException

getWorkingDirectory

public java.lang.String getWorkingDirectory()
Specified by:
getWorkingDirectory in interface Ftplett
Returns:
The current working directory

retrieve

@Nullable
public java.io.InputStream retrieve(java.lang.String fileName)
                             throws java.io.IOException
Specified by:
retrieve in interface Ftplett
Returns:
An InputStream producing the contents of the resource, or null iff the resource cannot be accessed.
Throws:
java.io.IOException

store

public java.io.OutputStream store(java.lang.String fileName)
                           throws java.io.IOException
Specified by:
store in interface Ftplett
Returns:
An OutputStream to which the contents can be written, or null iff the resource cannot be accessed.
Throws:
java.io.IOException

list

public boolean list(@Nullable
                    java.lang.String name,
                    ConsumerWhichThrows<java.lang.String,java.io.IOException> out)
             throws java.io.IOException
Specified by:
list in interface Ftplett
Parameters:
name - The name of the directory or file to list, or null to list the current working directory
out - Consumes the listing
Throws:
java.io.IOException

nameList

public boolean nameList(@Nullable
                        java.lang.String name,
                        ConsumerWhichThrows<java.lang.String,java.io.IOException> out)
                 throws java.io.IOException
Specified by:
nameList in interface Ftplett
Parameters:
name - The name of the directory or file to list, or null to list the current working directory
out - Consumes the listing
Throws:
java.io.IOException

delete

public boolean delete(java.lang.String resourceName)
               throws java.io.IOException
Specified by:
delete in interface Ftplett
Returns:
Whether the resource was successfully deleted
Throws:
java.io.IOException

rename

public boolean rename(java.lang.String from,
                      java.lang.String to)
               throws java.io.IOException
Specified by:
rename in interface Ftplett
Returns:
Whether the resource was successfully renamed
Throws:
java.io.IOException

getModificationTime

@Nullable
public java.util.Date getModificationTime(java.lang.String resourceName)
                                   throws java.io.IOException
Specified by:
getModificationTime in interface Ftplett
Returns:
null iff the modification time cannot be determined
Throws:
java.io.IOException