com.mucommander.job
Class CalculateChecksumJob

java.lang.Object
  extended by com.mucommander.job.FileJob
      extended by com.mucommander.job.TransferFileJob
          extended by com.mucommander.job.CalculateChecksumJob
All Implemented Interfaces:
java.lang.Runnable

public class CalculateChecksumJob
extends TransferFileJob

This job calculates a checksum for a list of files and stores the results in a checksum file.

The format of this file is a de facto standard ; a line is created for each file and goes like this:

 e7e9576b9e55940b4b8522a65902d4cd  readme.txt
 119abda7c941135d5bf382c386bca2ca  i386/debian-40r1-i386-DVD-1.iso
 3c0d332902b9b8dfec43ba02d1618c6e  ppc/debian-40r1-ppc-DVD-1.iso
 ...
 
The path of each file is relative to the checksum file's path. In the above example, readme.txt and the checksum file are located in the same folder. Note that 2 space characters (and not just one as anyone in his right mind would think) separate the hexadecimal checksum from the file path.

The above file format is used for all checksum algorithms but one: CRC32, which uses the special SFV format where the checksum for each file is written as follow:

 wne-ebai.r00 697115b2
 wne-ebai.r01 f80a8443
 ...
 

Author:
Maxence Bernard

Field Summary
 
Fields inherited from class com.mucommander.job.FileJob
APPEND_ACTION, APPEND_TEXT, baseSourceFolder, CANCEL_ACTION, CANCEL_TEXT, currentFile, currentFileIndex, currentFilename, files, FINISHED, INTERRUPTED, mainFrame, nbFiles, NOT_STARTED, PAUSED, progressDialog, RETRY_ACTION, RETRY_TEXT, RUNNING, SKIP_ACTION, SKIP_TEXT
 
Constructor Summary
CalculateChecksumJob(ProgressDialog progressDialog, MainFrame mainFrame, FileSet files, AbstractFile checksumFile, java.security.MessageDigest digest)
           
 
Method Summary
protected  boolean hasFolderChanged(AbstractFile folder)
          Returns true if the given folder has or may have been modified by this job.
protected  void jobCompleted()
          This method is called when this job has completed normal execution : all files have been processed without any interruption (without any call to FileJob.interrupt()).
protected  void jobStarted()
          This method is called when this job starts, before the first call to FileJob.processFile(AbstractFile,Object) is made.
protected  void jobStopped()
          Overrides FileJob.jobStopped() to stop any file processing by closing the source InputStream.
protected  boolean processFile(AbstractFile file, java.lang.Object recurseParams)
          Automatically called by FileJob.run() for each file that needs to be processed.
 
Methods inherited from class com.mucommander.job.TransferFileJob
closeCurrentInputStream, copyFile, getCurrentFileByteCounter, getCurrentFileSize, getCurrentFileSkippedByteCounter, getFilePercentDone, getStatusString, getThroughputLimit, getTotalByteCounter, getTotalPercentDone, getTotalSkippedByteCounter, isCheckingIntegrity, isIntegrityCheckEnabled, jobPaused, jobResumed, nextFile, setCurrentInputStream, setIntegrityCheckEnabled, setThroughputLimit, skipCurrentFile, tryCopyFile, wasCurrentFileSkipped
 
Methods inherited from class com.mucommander.job.FileJob
addFileJobListener, getCurrentFileIndex, getCurrentFilename, getEffectiveJobTime, getEndDate, getNbFiles, getPausedTime, getPauseStartDate, getStartDate, getState, interrupt, refreshTables, removeFileJobListener, run, selectFileWhenFinished, setAutoUnmark, setPaused, setState, showErrorDialog, showErrorDialog, start, waitForUserResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CalculateChecksumJob

public CalculateChecksumJob(ProgressDialog progressDialog,
                            MainFrame mainFrame,
                            FileSet files,
                            AbstractFile checksumFile,
                            java.security.MessageDigest digest)
Method Detail

processFile

protected boolean processFile(AbstractFile file,
                              java.lang.Object recurseParams)
Description copied from class: FileJob
Automatically called by FileJob.run() for each file that needs to be processed.

Specified by:
processFile in class FileJob
Parameters:
file - the file or folder to process
recurseParams - array of parameters which can be used when calling this method recursively, contains null when called by FileJob.run()
Returns:
true if the operation was sucessful

hasFolderChanged

protected boolean hasFolderChanged(AbstractFile folder)
Description copied from class: FileJob
Returns true if the given folder has or may have been modified by this job. This method is called after this job has finished processing files, to determine if the current MainFrame's file tables need to be refreshed to reveal the modified contents.

Specified by:
hasFolderChanged in class FileJob
Parameters:
folder - the folder to test
Returns:
true if the given folder has or may have been modified by this job

jobStarted

protected void jobStarted()
Description copied from class: FileJob
This method is called when this job starts, before the first call to FileJob.processFile(AbstractFile,Object) is made. This method implementation does nothing but it can be overriden by subclasses to perform some first-time initializations.

Overrides:
jobStarted in class FileJob

jobCompleted

protected void jobCompleted()
Description copied from class: FileJob
This method is called when this job has completed normal execution : all files have been processed without any interruption (without any call to FileJob.interrupt()).

The call happens after the last call to FileJob.processFile(AbstractFile,Object) is made. This method implementation does nothing but it can be overriden by subclasses to properly complete the job.

Note that this method will NOT be called if a call to FileJob.interrupt() was made before all files were processed.

Overrides:
jobCompleted in class FileJob

jobStopped

protected void jobStopped()
Description copied from class: TransferFileJob
Overrides FileJob.jobStopped() to stop any file processing by closing the source InputStream.

Overrides:
jobStopped in class TransferFileJob


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard