org.apache.camel.component.file
Class FileOperations

java.lang.Object
  extended by org.apache.camel.component.file.FileOperations
All Implemented Interfaces:
GenericFileOperations<File>

public class FileOperations
extends Object
implements GenericFileOperations<File>

File operations for File.


Constructor Summary
FileOperations()
           
FileOperations(FileEndpoint endpoint)
           
 
Method Summary
 boolean buildDirectory(String directory, boolean absolute)
          Builds the directory structure.
 void changeCurrentDirectory(String path)
          Change the current remote directory
 void changeToParentDirectory()
          Change the current remote directory to the parent
 boolean deleteFile(String name)
          Deletes the file name by name, relative to the current directory
 boolean existsFile(String name)
          Determines whether the files exists or not
 String getCurrentDirectory()
          Gets the current remote directory
 List<File> listFiles()
          List the files in the current directory
 List<File> listFiles(String path)
          List the files in the given remote directory
 boolean renameFile(String from, String to)
          Renames the file
 boolean retrieveFile(String name, Exchange exchange)
          Retrieves the file
 void setEndpoint(GenericFileEndpoint<File> endpoint)
          Sets the endpoint as some implementations need access to the endpoint and how its configured.
 boolean storeFile(String fileName, Exchange exchange)
          Stores the content as a new remote file (upload)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileOperations

public FileOperations()

FileOperations

public FileOperations(FileEndpoint endpoint)
Method Detail

setEndpoint

public void setEndpoint(GenericFileEndpoint<File> endpoint)
Description copied from interface: GenericFileOperations
Sets the endpoint as some implementations need access to the endpoint and how its configured.

Specified by:
setEndpoint in interface GenericFileOperations<File>
Parameters:
endpoint - the endpoint

deleteFile

public boolean deleteFile(String name)
                   throws GenericFileOperationFailedException
Description copied from interface: GenericFileOperations
Deletes the file name by name, relative to the current directory

Specified by:
deleteFile in interface GenericFileOperations<File>
Parameters:
name - name of the file
Returns:
true if deleted, false if not
Throws:
GenericFileOperationFailedException - can be thrown

renameFile

public boolean renameFile(String from,
                          String to)
                   throws GenericFileOperationFailedException
Description copied from interface: GenericFileOperations
Renames the file

Specified by:
renameFile in interface GenericFileOperations<File>
Parameters:
from - original name
to - the new name
Returns:
true if renamed, false if not
Throws:
GenericFileOperationFailedException - can be thrown

existsFile

public boolean existsFile(String name)
                   throws GenericFileOperationFailedException
Description copied from interface: GenericFileOperations
Determines whether the files exists or not

Specified by:
existsFile in interface GenericFileOperations<File>
Parameters:
name - name of the file
Returns:
true if exists, false if not
Throws:
GenericFileOperationFailedException - can be thrown

buildDirectory

public boolean buildDirectory(String directory,
                              boolean absolute)
                       throws GenericFileOperationFailedException
Description copied from interface: GenericFileOperations
Builds the directory structure. Will test if the folder already exists.

Specified by:
buildDirectory in interface GenericFileOperations<File>
Parameters:
directory - the directory path to build as a relative string name
absolute - wether the directory is an absolute or relative path
Returns:
true if build or already exists, false if not possible (could be lack of permissions)
Throws:
GenericFileOperationFailedException - can be thrown

listFiles

public List<File> listFiles()
                     throws GenericFileOperationFailedException
Description copied from interface: GenericFileOperations
List the files in the current directory

Specified by:
listFiles in interface GenericFileOperations<File>
Returns:
a list of backing objects representing the files
Throws:
GenericFileOperationFailedException - can be thrown

listFiles

public List<File> listFiles(String path)
                     throws GenericFileOperationFailedException
Description copied from interface: GenericFileOperations
List the files in the given remote directory

Specified by:
listFiles in interface GenericFileOperations<File>
Parameters:
path - the remote directory
Returns:
a list of backing objects representing the files
Throws:
GenericFileOperationFailedException - can be thrown

changeCurrentDirectory

public void changeCurrentDirectory(String path)
                            throws GenericFileOperationFailedException
Description copied from interface: GenericFileOperations
Change the current remote directory

Specified by:
changeCurrentDirectory in interface GenericFileOperations<File>
Parameters:
path - the path to change to
Throws:
GenericFileOperationFailedException - can be thrown

changeToParentDirectory

public void changeToParentDirectory()
                             throws GenericFileOperationFailedException
Description copied from interface: GenericFileOperations
Change the current remote directory to the parent

Specified by:
changeToParentDirectory in interface GenericFileOperations<File>
Throws:
GenericFileOperationFailedException - can be thrown

getCurrentDirectory

public String getCurrentDirectory()
                           throws GenericFileOperationFailedException
Description copied from interface: GenericFileOperations
Gets the current remote directory

Specified by:
getCurrentDirectory in interface GenericFileOperations<File>
Returns:
the current directory path
Throws:
GenericFileOperationFailedException - can be thrown

retrieveFile

public boolean retrieveFile(String name,
                            Exchange exchange)
                     throws GenericFileOperationFailedException
Description copied from interface: GenericFileOperations
Retrieves the file

Specified by:
retrieveFile in interface GenericFileOperations<File>
Parameters:
name - name of the file
exchange - stream to write the content of the file into
Returns:
true if file has been retrieved, false if not
Throws:
GenericFileOperationFailedException - can be thrown

storeFile

public boolean storeFile(String fileName,
                         Exchange exchange)
                  throws GenericFileOperationFailedException
Description copied from interface: GenericFileOperations
Stores the content as a new remote file (upload)

Specified by:
storeFile in interface GenericFileOperations<File>
Parameters:
fileName - name of new file
exchange - with the content content of the file
Returns:
true if the file was stored, false if not
Throws:
GenericFileOperationFailedException - can be thrown


Apache CAMEL