This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Mocks the functionality of FileHanlder without actually querying the FileSystem.
- Author:
- Shehab.Kamal
|
Method Summary |
boolean |
createFolder(java.lang.String parentFolder,
java.lang.String folderName)
When ovevrridden in a derived class creates a folder at the specified location. |
boolean |
createPath(java.lang.String path)
When overridden in a derived class creates the complete path. |
boolean |
deleteFolder(java.lang.String path,
boolean recursive)
When overridden in a derived class deletes the folder and its subfolders. |
boolean |
downloadFile(java.lang.String sourcePath,
java.lang.String fileName,
java.lang.String destinationPath,
java.lang.String newName)
When overridden in a derived class downloads the file from source to destination. |
boolean |
downloadFiles(java.lang.String source,
java.lang.String extention,
java.lang.String destination)
When overridden in a derived class downloads the files with the given extention from source to destination. |
boolean |
downloadFolder(java.lang.String source,
java.lang.String folderName,
java.lang.String destination,
java.lang.String newName)
When overridden in a derived class downloads a folder from source to destination. |
boolean |
folderExists(java.lang.String folderPath)
When overridden in a derived class determines whether the folder exists or not. |
java.io.File[] |
getFiles(java.lang.String parentFolder)
When overridden in a derived class gets the files within the given folder. |
java.io.File[] |
getFiles(java.lang.String parentFolder,
java.lang.String extention)
When overridden in a derived class gets the files with a specific extention within the given folder. |
int |
getFilesCount(java.lang.String parentFolder)
When overridden in a derived class gets the count of files within the given folder. |
int |
getFilesCount(java.lang.String parentFolder,
java.lang.String extention)
When overridden in a derived class gets the count of files with a specific extention within the given folder. |
int |
getFilesCountRecursively(java.lang.String parentFolder)
When overridden in a derived class gets the count of files within the given folder recursively. |
long |
getFileSize(java.lang.String filePath)
When ovevrridden in a derived class gets the size of the file. |
java.lang.String[] |
getFilesNames(java.lang.String parentFolder)
When overridden in a derived class gets the names of the files within the given folder. |
java.lang.String[] |
getFilesNames(java.lang.String parentFolder,
java.lang.String extention)
When overridden in a derived class gets the names of the files with a specific extention within the given folder. |
java.io.File[] |
getFilesRecursively(java.lang.String parentFolder)
When overridden in a derived class gets the files within the given folder recursively |
long |
getFolderSize(java.lang.String folderPath)
When ovevrridden in a derived class gets the size of the size of the folder recursively. |
java.lang.String[] |
getSubFolders(java.lang.String parentFolder)
When overridden in a derived class gets a list of subfolders within the given folder. |
boolean |
uploadFile(java.lang.String sourcePath,
java.lang.String fileName,
java.lang.String destinationPath,
java.lang.String newName)
When overridden in a derived class uploads the file from source to destination. |
boolean |
uploadFiles(java.lang.String source,
java.lang.String extention,
java.lang.String destination)
When overridden in a derived class uploads the files with the given extention from source to destination. |
boolean |
uploadFolder(java.lang.String source,
java.lang.String folderName,
java.lang.String destination,
java.lang.String newName)
When overridden in a derived class uploads a folder from source to destination. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MockFileHandler
public MockFileHandler()
createFolder
public boolean createFolder(java.lang.String parentFolder,
java.lang.String folderName)
- Description copied from class:
FileHandler
- When ovevrridden in a derived class creates a folder at the specified location.
- Specified by:
createFolder in class FileHandler
- Parameters:
parentFolder - The parent folder path.folderName - The name of the folder to create
- Returns:
- True if the folder has been created, otherwise false.
downloadFolder
public boolean downloadFolder(java.lang.String source,
java.lang.String folderName,
java.lang.String destination,
java.lang.String newName)
- Description copied from class:
FileHandler
- When overridden in a derived class downloads a folder from source to destination.
- Specified by:
downloadFolder in class FileHandler
- Parameters:
source - The source parent folder.folderName - The name of the folder to copy.destination - The destination parent folder.newName - The new name of the folder after copying.
- Returns:
- True if the folder has been copied, otherwise false.
uploadFolder
public boolean uploadFolder(java.lang.String source,
java.lang.String folderName,
java.lang.String destination,
java.lang.String newName)
- Description copied from class:
FileHandler
- When overridden in a derived class uploads a folder from source to destination.
- Specified by:
uploadFolder in class FileHandler
- Parameters:
source - The source parent folder.folderName - The name of the folder to copy.destination - The destination parent folder.newName - The new name of the folder after copying.
- Returns:
- True if the folder has been copied, otherwise false.
downloadFiles
public boolean downloadFiles(java.lang.String source,
java.lang.String extention,
java.lang.String destination)
- Description copied from class:
FileHandler
- When overridden in a derived class downloads the files with the given extention from source to destination.
- Specified by:
downloadFiles in class FileHandler
- Parameters:
source - The source folder that contain the files.extention - The extension of the files to be copied.;destination - The destination folder to which the files will be copied.
- Returns:
- True if the files have been copied successfully, otherwise false.
uploadFiles
public boolean uploadFiles(java.lang.String source,
java.lang.String extention,
java.lang.String destination)
- Description copied from class:
FileHandler
- When overridden in a derived class uploads the files with the given extention from source to destination.
- Specified by:
uploadFiles in class FileHandler
- Parameters:
source - The source folder that contain the files.extention - The extension of the files to be copied.;destination - The destination folder to which the files will be copied.
- Returns:
- True if the files have been copied successfully, otherwise false.
deleteFolder
public boolean deleteFolder(java.lang.String path,
boolean recursive)
- Description copied from class:
FileHandler
- When overridden in a derived class deletes the folder and its subfolders.
- Specified by:
deleteFolder in class FileHandler
- Parameters:
path - The path of the folder.recursive - Whether to delete subfiles and subfolders or not.
- Returns:
- True if the folder has been deleted, otherwise false.
getSubFolders
public java.lang.String[] getSubFolders(java.lang.String parentFolder)
- Description copied from class:
FileHandler
- When overridden in a derived class gets a list of subfolders within the given folder.
- Specified by:
getSubFolders in class FileHandler
- Parameters:
parentFolder - The folder to get its subfolders.
- Returns:
- A list of folder within the given folder. If there is not any folders an empty array is returned.
getFilesCount
public int getFilesCount(java.lang.String parentFolder,
java.lang.String extention)
- Description copied from class:
FileHandler
- When overridden in a derived class gets the count of files with a specific extention within the given folder.
- Specified by:
getFilesCount in class FileHandler
- Parameters:
parentFolder - The folder to get the count of files within it.extention - The extention of the files to count.
- Returns:
- The number of files within the folder.
getFilesCount
public int getFilesCount(java.lang.String parentFolder)
- Description copied from class:
FileHandler
- When overridden in a derived class gets the count of files within the given folder.
- Specified by:
getFilesCount in class FileHandler
- Parameters:
parentFolder - The folder to get the count of files within it.
- Returns:
- The number of files within the folder.
folderExists
public boolean folderExists(java.lang.String folderPath)
- Description copied from class:
FileHandler
- When overridden in a derived class determines whether the folder exists or not.
- Specified by:
folderExists in class FileHandler
- Parameters:
folderPath - The folder path.
- Returns:
- True if the folder exists otherwise false.
getFiles
public java.io.File[] getFiles(java.lang.String parentFolder)
- Description copied from class:
FileHandler
- When overridden in a derived class gets the files within the given folder.
- Specified by:
getFiles in class FileHandler
- Parameters:
parentFolder - The folder to get the files within it.
- Returns:
- The files within the folder.
getFiles
public java.io.File[] getFiles(java.lang.String parentFolder,
java.lang.String extention)
- Description copied from class:
FileHandler
- When overridden in a derived class gets the files with a specific extention within the given folder.
- Specified by:
getFiles in class FileHandler
- Parameters:
parentFolder - The folder to get the files within it.extention - The extention of the files to get.
- Returns:
- The files within the folder.
createPath
public boolean createPath(java.lang.String path)
- Description copied from class:
FileHandler
- When overridden in a derived class creates the complete path.
- Specified by:
createPath in class FileHandler
- Parameters:
path - The path to create.
- Returns:
- True if the path has been created or already exists otherwise false.
getFilesNames
public java.lang.String[] getFilesNames(java.lang.String parentFolder)
- Description copied from class:
FileHandler
- When overridden in a derived class gets the names of the files within the given folder.
- Specified by:
getFilesNames in class FileHandler
- Parameters:
parentFolder - The folder to get the names of the files within it.
- Returns:
- The names of the files within the folder.
getFilesNames
public java.lang.String[] getFilesNames(java.lang.String parentFolder,
java.lang.String extention)
- Description copied from class:
FileHandler
- When overridden in a derived class gets the names of the files with a specific extention within the given folder.
- Specified by:
getFilesNames in class FileHandler
- Parameters:
parentFolder - The folder to get the names of the files within it.extention - The extention of the files to get its name.
- Returns:
- The names of the files within the folder.
getFileSize
public long getFileSize(java.lang.String filePath)
- Description copied from class:
FileHandler
- When ovevrridden in a derived class gets the size of the file.
- Specified by:
getFileSize in class FileHandler
- Parameters:
filePath - The complete path of the the file, that is: parent folder + file name + extension.
- Returns:
- The size of the file in byte.
getFolderSize
public long getFolderSize(java.lang.String folderPath)
- Description copied from class:
FileHandler
- When ovevrridden in a derived class gets the size of the size of the folder recursively.
- Specified by:
getFolderSize in class FileHandler
- Parameters:
folderPath - The complete path of the the folder, that is: parent folder + folder name.
- Returns:
- The size of the folder in bytes.
getFilesCountRecursively
public int getFilesCountRecursively(java.lang.String parentFolder)
- Description copied from class:
FileHandler
- When overridden in a derived class gets the count of files within the given folder recursively.
- Specified by:
getFilesCountRecursively in class FileHandler
- Parameters:
parentFolder - The folder to get the count of files within it.
- Returns:
- The number of files within the folder.
getFilesRecursively
public java.io.File[] getFilesRecursively(java.lang.String parentFolder)
- Description copied from class:
FileHandler
- When overridden in a derived class gets the files within the given folder recursively
- Specified by:
getFilesRecursively in class FileHandler
- Parameters:
parentFolder - The folder to get the files within it.
- Returns:
- The files within the folder.
downloadFile
public boolean downloadFile(java.lang.String sourcePath,
java.lang.String fileName,
java.lang.String destinationPath,
java.lang.String newName)
- Description copied from class:
FileHandler
- When overridden in a derived class downloads the file from source to destination.
- Specified by:
downloadFile in class FileHandler
- Parameters:
sourcePath - The path of the source folder containg the file.fileName - The name of the file within the source folder to copy.destinationPath - The path of the destination folder.newName - The new name of the file at the destination folder.
- Returns:
- True if the file has been uploaded otherwise false.
uploadFile
public boolean uploadFile(java.lang.String sourcePath,
java.lang.String fileName,
java.lang.String destinationPath,
java.lang.String newName)
- Description copied from class:
FileHandler
- When overridden in a derived class uploads the file from source to destination.
- Specified by:
uploadFile in class FileHandler
- Parameters:
sourcePath - The path of the source folder containg the file.fileName - The name of the file within the source folder to copy.destinationPath - The path of the destination folder.newName - The new name of the file at the destination folder.
- Returns:
- True if the file has been uploaded otherwise false.