Package thredds.util.filesource
Class BasicDescendantFileSource
java.lang.Object
thredds.util.filesource.BasicDescendantFileSource
- All Implemented Interfaces:
DescendantFileSource,FileSource
_more_
- Since:
- 4.0
-
Constructor Summary
ConstructorsConstructorDescriptionBasicDescendantFileSource(File rootDirectory) BasicDescendantFileSource(String rootDirectoryPath) -
Method Summary
Modifier and TypeMethodDescriptiongetDescendant(String relativePath) Return a DescendantFileSource representing the descendant directory specified by the relative path.This implementation requires the path to be relative to the root directory and a descendant of the root directory.getRelativePath(File file) Return the path relative to the root directory that represents the given descendant file.getRelativePath(String filePath) Return the path relative to the root directory that represents the given descendant file path.Return the root directory represented by this FileLocator as a java.io.File.Return the path of the root directory represented by this FileLocator.booleanisDescendant(File file) Return true if the given File is an existing descendant of the root directory, false otherwise.booleanisDescendant(String filePath) Return true if the given file path is an existing descendant of the root directory, false otherwise.toString()
-
Constructor Details
-
BasicDescendantFileSource
-
BasicDescendantFileSource
-
-
Method Details
-
getFile
This implementation requires the path to be relative to the root directory and a descendant of the root directory. It also requires the relative path at each path segment to be a descendant of the root directory, i.e., it cannot start with "../" or contain "../" path segments such that once "normalized" it would start with "../" (e.g., "dir1/../../dir2" once normalized would be "../dir2").- Specified by:
getFilein interfaceFileSource- Parameters:
path- the relative path to the descendant File.- Returns:
- the descendant File represented by the given relative path or null if the path is null, not relative to the root, not a descendant, or the File doesn't exist.
-
getDescendant
Description copied from interface:DescendantFileSourceReturn a DescendantFileSource representing the descendant directory specified by the relative path.- Specified by:
getDescendantin interfaceDescendantFileSource- Parameters:
relativePath- the relative path to the descendant directory.- Returns:
- a FileLocator representing the descendant root directory or null if the path is null or the descendant directory doesn't exist or isn't a directory (or isn't a descendant).
-
getRootDirectory
Description copied from interface:DescendantFileSourceReturn the root directory represented by this FileLocator as a java.io.File.- Specified by:
getRootDirectoryin interfaceDescendantFileSource- Returns:
- the root directory represented by this FileLocator.
-
getRootDirectoryPath
Description copied from interface:DescendantFileSourceReturn the path of the root directory represented by this FileLocator.- Specified by:
getRootDirectoryPathin interfaceDescendantFileSource- Returns:
- the path of the root directory represented by this FileLocator.
-
isDescendant
Description copied from interface:DescendantFileSourceReturn true if the given File is an existing descendant of the root directory, false otherwise.- Specified by:
isDescendantin interfaceDescendantFileSource- Parameters:
file- the File to be checked if it is a descendant.- Returns:
- true if the given file is an existing descendant, false otherwise.
-
isDescendant
Description copied from interface:DescendantFileSourceReturn true if the given file path is an existing descendant of the root directory, false otherwise.- Specified by:
isDescendantin interfaceDescendantFileSource- Parameters:
filePath- the file path to be checked if it is a descendant.- Returns:
- true if the given file path represents an existing descendant, false otherwise.
-
getRelativePath
Description copied from interface:DescendantFileSourceReturn the path relative to the root directory that represents the given descendant file.- Specified by:
getRelativePathin interfaceDescendantFileSource- Parameters:
file- the File for which the relative path is to be determined.- Returns:
- the path relative to the root directory that represents the given descendant file or null if the given file is null or not a descendant.
-
getRelativePath
Description copied from interface:DescendantFileSourceReturn the path relative to the root directory that represents the given descendant file path.- Specified by:
getRelativePathin interfaceDescendantFileSource- Parameters:
filePath- the file path for which the relative path is to be determined.- Returns:
- the path relative to the root directory that represents the given descendant file path or null if the given file path is null or not a descendant.
-
toString
-