Class PathDifference

Object
PathDifference

public class PathDifference extends Object
Calculates the "difference" between a path and a base.

e.g. if a base is c:\root\somePrefix_ and a file is c:\root\somePrefix_someFile.xml then the difference is _someFile.xml

The difference is recorded separately as directory and filename components.

Internally, both paths are converted to absolute paths and URIs.

Author:
Owen Feehan
  • Method Details

    • differenceFrom

      public static PathDifference differenceFrom(Path baseDirectoryPath, Path filePath) throws PathDifferenceException
      Finds the difference between a path and a base.
      Parameters:
      baseDirectoryPath - path to a base directory.
      filePath - the path to resolve.
      Returns:
      the difference between the paths.
      Throws:
      PathDifferenceException - if the canonical file cannot be found.
    • combined

      public Path combined()
      The directory-component (if it exists) and filename-component combined.
      Returns:
      the combined-path
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getFilename

      public String getFilename()
      The file-name component of the difference, if it exists.
    • getDirectory

      public Optional<Path> getDirectory()
      The directory component of the difference, if it exists.