Package org.fastnate.data.files
Interface DataFolder
- All Known Implementing Classes:
FsDataFolder,VfsDataFolder
public interface DataFolder
Represents a folder from the file system or the classpath that contains data to import with a
DataProvider.- Author:
- Tobias Liefke
-
Method Summary
Modifier and TypeMethodDescriptiondefault DataFileFinds a file in this folder.default DataFolderfindFolder(String name) Finds a sub folder in this folder.default voidforAllFiles(BiConsumer<DataFolder, DataFile> consumer) Finds all files in this folder and in all sub folders and handles them with the given consumer.default voidforAllFiles(Consumer<DataFile> consumer) Finds all files in this folder and in all sub folders and handles them with the given consumer.getFiles()Finds all files inside this folder.default DataFolderFinds a sub folder in this folder.List<? extends DataFolder> Finds the all sub folders inside this folder.getName()The name of this folder.The parent folder of this folder.default DataFolderSplits the given path by '/' and returns the folder according to the single path elements.
-
Method Details
-
findFile
Finds a file in this folder.- Parameters:
name- the name of the file- Returns:
- the file or
nullif no file with such a name exists
-
findFolder
Finds a sub folder in this folder.- Parameters:
name- the name of the sub folder- Returns:
- the sub folder or
nullif no folder with such a name exists
-
forAllFiles
Finds all files in this folder and in all sub folders and handles them with the given consumer.- Parameters:
consumer- handles each of the files- Throws:
IOException- if one of the files was not accessible
-
forAllFiles
Finds all files in this folder and in all sub folders and handles them with the given consumer.- Parameters:
consumer- handles each of the files- Throws:
IOException- if one of the files was not accessible
-
getFiles
Finds all files inside this folder. Will not return a file from asub folder- Returns:
- the files in this folder
-
getFolder
Finds a sub folder in this folder.- Parameters:
name- the name of the sub folder- Returns:
- the sub folder or an empty folder, if no such folder exists
-
getFolders
List<? extends DataFolder> getFolders()Finds the all sub folders inside this folder.- Returns:
- the direct children of this folder
-
getName
String getName()The name of this folder.- Returns:
- the name of this folder, empty or
nullfor the root folder
-
getParent
DataFolder getParent()The parent folder of this folder.- Returns:
- the parent or
nullif this folder is the root folder
-
getPath
Splits the given path by '/' and returns the folder according to the single path elements.- Parameters:
path- the relative path to the folder from this folder- Returns:
- the folder for the given path
-