Class BasicDescendantFileSource

    • Constructor Detail

      • BasicDescendantFileSource

        public BasicDescendantFileSource​(File rootDirectory)
      • BasicDescendantFileSource

        public BasicDescendantFileSource​(String rootDirectoryPath)
    • Method Detail

      • getFile

        public File getFile​(String path)
        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:
        getFile in interface FileSource
        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

        public DescendantFileSource getDescendant​(String relativePath)
        Description copied from interface: DescendantFileSource
        Return a DescendantFileSource representing the descendant directory specified by the relative path.
        Specified by:
        getDescendant in interface DescendantFileSource
        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

        public File getRootDirectory()
        Description copied from interface: DescendantFileSource
        Return the root directory represented by this FileLocator as a java.io.File.
        Specified by:
        getRootDirectory in interface DescendantFileSource
        Returns:
        the root directory represented by this FileLocator.
      • getRootDirectoryPath

        public String getRootDirectoryPath()
        Description copied from interface: DescendantFileSource
        Return the path of the root directory represented by this FileLocator.
        Specified by:
        getRootDirectoryPath in interface DescendantFileSource
        Returns:
        the path of the root directory represented by this FileLocator.
      • isDescendant

        public boolean isDescendant​(File file)
        Description copied from interface: DescendantFileSource
        Return true if the given File is an existing descendant of the root directory, false otherwise.
        Specified by:
        isDescendant in interface DescendantFileSource
        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

        public boolean isDescendant​(String filePath)
        Description copied from interface: DescendantFileSource
        Return true if the given file path is an existing descendant of the root directory, false otherwise.
        Specified by:
        isDescendant in interface DescendantFileSource
        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

        public String getRelativePath​(File file)
        Description copied from interface: DescendantFileSource
        Return the path relative to the root directory that represents the given descendant file.
        Specified by:
        getRelativePath in interface DescendantFileSource
        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

        public String getRelativePath​(String filePath)
        Description copied from interface: DescendantFileSource
        Return the path relative to the root directory that represents the given descendant file path.
        Specified by:
        getRelativePath in interface DescendantFileSource
        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.