Class FileCommander

  • Direct Known Subclasses:
    AesFileCommander

    public class FileCommander
    extends java.lang.Object
    Facade class for file operations.
    • Constructor Detail

      • FileCommander

        public FileCommander​(FileImporter fileImporter,
                             FileExporter fileExporter,
                             FileSearcher fileSearcher)
        Instantiate a new file commander object.
        Parameters:
        fileImporter - The importer to use
        fileExporter - The exporter to use
        fileSearcher - The searcher to use
    • Method Detail

      • getFileImporter

        public FileImporter getFileImporter()
        Get the file importer.
        Returns:
        The file importer.
      • getFileExporter

        public FileExporter getFileExporter()
        Get the file exporter.
        Returns:
        The file exporter.
      • getFileSearcher

        public FileSearcher getFileSearcher()
        Get the file searcher.
        Returns:
        The file searcher.
      • importFiles

        public IVirtualFile[] importFiles​(IFile[] filesToImport,
                                          IVirtualFile importDir)
                                   throws java.lang.Exception
        Import IFile(s) into the drive.
        Parameters:
        filesToImport - The files to import.
        importDir - The target directory.
        Returns:
        The imported files.
        Throws:
        java.lang.Exception - Thrown if error occurs during import
      • importFiles

        public IVirtualFile[] importFiles​(IFile[] filesToImport,
                                          IVirtualFile importDir,
                                          FileCommander.BatchImportOptions options)
                                   throws java.lang.Exception
        Import IFile(s) into the drive.
        Parameters:
        filesToImport - The files to import.
        importDir - The target directory.
        options - The options
        Returns:
        The imported files.
        Throws:
        java.lang.Exception - Thrown if error occurs during import
      • exportFiles

        public IFile[] exportFiles​(IVirtualFile[] filesToExport,
                                   IFile exportDir)
                            throws java.lang.Exception
        Export IVirtualFile(s) from the drive.
        Parameters:
        filesToExport - The files to export.
        exportDir - The export target directory
        Returns:
        The exported files
        Throws:
        java.lang.Exception - Thrown if error occurs during export
      • exportFiles

        public IFile[] exportFiles​(IVirtualFile[] filesToExport,
                                   IFile exportDir,
                                   FileCommander.BatchExportOptions options)
                            throws java.lang.Exception
        Export IVirtualFile(s) from the drive.
        Parameters:
        filesToExport - The files to export.
        exportDir - The export target directory
        options - The options
        Returns:
        The exported files
        Throws:
        java.lang.Exception - Thrown if error occurs during export
      • deleteFiles

        public void deleteFiles​(IVirtualFile[] filesToDelete)
        Delete files from a drive.
        Parameters:
        filesToDelete - The files to delete.
      • copyFiles

        public void copyFiles​(IVirtualFile[] filesToCopy,
                              IVirtualFile dir,
                              FileCommander.BatchCopyOptions options)
                       throws java.lang.Exception
        Copy files to another directory.
        Parameters:
        filesToCopy - The array of files to copy.
        dir - The target directory.
        options - The options
        Throws:
        java.lang.Exception - Thrown if error occurs during copying
      • cancel

        public void cancel()
        Cancel all jobs.
      • isFileSearcherRunning

        public boolean isFileSearcherRunning()
        Check if file search is currently running.
        Returns:
        True if search is running
      • isRunning

        public boolean isRunning()
        Check if jobs are currently running.
        Returns:
        True if a job is running
      • isFileSearcherStopped

        public boolean isFileSearcherStopped()
        Check if file search stopped.
        Returns:
        True if file search is stopped
      • stopFileSearch

        public void stopFileSearch()
        Stop the current file search.
      • search

        public IVirtualFile[] search​(IVirtualFile dir,
                                     java.lang.String terms)
        Search for files in a drive.
        Parameters:
        dir - The directory to start the search.
        terms - The terms to search for.
        Returns:
        An array with all the results found.
      • search

        public IVirtualFile[] search​(IVirtualFile dir,
                                     java.lang.String terms,
                                     FileSearcher.SearchOptions options)
        Search for files in a drive.
        Parameters:
        dir - The directory to start the search.
        terms - The terms to search for.
        options - The options
        Returns:
        An array with all the results found.
      • areJobsStopped

        public boolean areJobsStopped()
        Check if all jobs are stopped.
        Returns:
        True if jobs are stopped
      • close

        public void close()
        Close the commander and release resources.
      • renameFile

        public void renameFile​(IVirtualFile ifile,
                               java.lang.String newFilename)
                        throws java.io.IOException
        Rename an encrypted file
        Parameters:
        ifile - The file to rename
        newFilename - The new file name
        Throws:
        java.io.IOException - Thrown if there is an IO error.
      • onError

        protected boolean onError​(java.lang.Exception ex)
                           throws java.lang.Exception
        Handler the error. If true the commander will proceed with the next file otherwise it will stop the batch. You can override this in your implementation.
        Parameters:
        ex - The exception
        Returns:
        True if recoverable
        Throws:
        java.lang.Exception - If error occurs