Package com.mku.fs.drive.utils
Class FileCommander
- java.lang.Object
-
- com.mku.fs.drive.utils.FileCommander
-
- Direct Known Subclasses:
AesFileCommander
public class FileCommander extends java.lang.ObjectFacade class for file operations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFileCommander.BatchCopyOptionsBatch copy optionsstatic classFileCommander.BatchDeleteOptionsBatch delete optionsstatic classFileCommander.BatchExportOptionsBatch export optionsstatic classFileCommander.BatchImportOptionsBatch import optionsclassFileCommander.RealFileTaskProgressTask progress for IFile(s).classFileCommander.VirtualFileTaskProgressTask progress for IVirtualFile(s).
-
Constructor Summary
Constructors Constructor Description FileCommander(FileImporter fileImporter, FileExporter fileExporter, FileSearcher fileSearcher)Instantiate a new file commander object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanareJobsStopped()Check if all jobs are stopped.voidcancel()Cancel all jobs.voidclose()Close the commander and release resources.voidcopyFiles(IVirtualFile[] filesToCopy, IVirtualFile dir, FileCommander.BatchCopyOptions options)Copy files to another directory.voiddeleteFiles(IVirtualFile[] filesToDelete)Delete files from a drive.voiddeleteFiles(IVirtualFile[] filesToDelete, FileCommander.BatchDeleteOptions options)Delete files from a drive.IFile[]exportFiles(IVirtualFile[] filesToExport, IFile exportDir)Export IVirtualFile(s) from the drive.IFile[]exportFiles(IVirtualFile[] filesToExport, IFile exportDir, FileCommander.BatchExportOptions options)Export IVirtualFile(s) from the drive.FileExportergetFileExporter()Get the file exporter.FileImportergetFileImporter()Get the file importer.FileSearchergetFileSearcher()Get the file searcher.IVirtualFile[]importFiles(IFile[] filesToImport, IVirtualFile importDir)Import IFile(s) into the drive.IVirtualFile[]importFiles(IFile[] filesToImport, IVirtualFile importDir, FileCommander.BatchImportOptions options)Import IFile(s) into the drive.booleanisFileSearcherRunning()Check if file search is currently running.booleanisFileSearcherStopped()Check if file search stopped.booleanisRunning()Check if jobs are currently running.protected booleanonError(java.lang.Exception ex)Handler the error.voidrenameFile(IVirtualFile ifile, java.lang.String newFilename)Rename an encrypted fileIVirtualFile[]search(IVirtualFile dir, java.lang.String terms)Search for files in a drive.IVirtualFile[]search(IVirtualFile dir, java.lang.String terms, FileSearcher.SearchOptions options)Search for files in a drive.voidstopFileSearch()Stop the current file search.
-
-
-
Constructor Detail
-
FileCommander
public FileCommander(FileImporter fileImporter, FileExporter fileExporter, FileSearcher fileSearcher)
Instantiate a new file commander object.- Parameters:
fileImporter- The importer to usefileExporter- The exporter to usefileSearcher- 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 directoryoptions- 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.
-
deleteFiles
public void deleteFiles(IVirtualFile[] filesToDelete, FileCommander.BatchDeleteOptions options)
Delete files from a drive.- Parameters:
filesToDelete- The files to delete.options- The options
-
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 renamenewFilename- 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.ExceptionHandler 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
-
-