Class FileChangeDetector

java.lang.Object
de.iip_ecosphere.platform.tools.maven.python.FileChangeDetector

public class FileChangeDetector extends Object
A simple MD5-hash based file change detector.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • FileChangeDetector

      public FileChangeDetector(File md5File, Logger logger, String task)
      Creates a file change detector instance.
      Parameters:
      md5File - the file where the hashes are/shall be stored
      logger - the logger instance
      task - a task description for logging (may be null or empty for no logging)
  • Method Details

    • useHash

      public FileChangeDetector useHash(boolean useHash)
      Enable/disable the detector.
      Parameters:
      useHash - whether the detector/hashing shall be used
      Returns:
      this (builder style)
    • readHashFile

      public void readHashFile()
      Reads the MD5 hash file.
    • writeHashFile

      public void writeHashFile()
      Writes md5Hashes to the hash file.
    • remove

      public void remove(File file)
      Removes file from the hashes.
      Parameters:
      file - the file to remove
    • getHashFilePath

      private String getHashFilePath(File file)
      Returns the file path to be used for MD5 hashing of file.
      Parameters:
      file - the file
      Returns:
      the file path
    • checkHashes

      public List<File> checkHashes(List<File> files)
      Checks files for existing/known hashes.
      Parameters:
      files - the files
      Returns:
      a subset of files to process
    • getHashFileInTarget

      public static File getHashFileInTarget(org.apache.maven.project.MavenProject project, String hashFileName)
      Returns the name of a hash file with #FILE_EXTENSION in the maven target folder.
      Parameters:
      project - the project determining the maven target folder
      hashFileName - the name of the hash file
      Returns:
      the hash file