org.apache.felix.fileinstall.internal
Class Scanner

java.lang.Object
  extended by org.apache.felix.fileinstall.internal.Scanner

public class Scanner
extends Object

A Scanner object is able to detect and report new, modified and deleted files. The scanner use an internal checksum to identify the signature of a file or directory. The checksum will change if the file or any of the directory's child is modified. In addition, if the scanner detects a change on a given file, it will wait until the checksum does not change anymore before reporting the change on this file. This allows to not report the change until a big copy if complete for example.


Constructor Summary
Scanner(File directory)
          Create a scanner for the specified directory
Scanner(File directory, FilenameFilter filter)
          Create a scanner for the specified directory and file filter
 
Method Summary
 long getChecksum(File file)
          Retrieve the previously computed checksum for a give file.
 void initialize(Map checksums)
          Initialize the list of known files.
 Set scan(boolean reportImmediately)
          Report a set of new, modified or deleted files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scanner

public Scanner(File directory)
Create a scanner for the specified directory

Parameters:
directory - the directory to scan

Scanner

public Scanner(File directory,
               FilenameFilter filter)
Create a scanner for the specified directory and file filter

Parameters:
directory - the directory to scan
filter - a filter for file names
Method Detail

initialize

public void initialize(Map checksums)
Initialize the list of known files. This should be called before the first scan to initialize the list of known files. The purpose is to be able to detect files that have been deleted while the scanner was inactive.

Parameters:
checksums - a map of checksums

scan

public Set scan(boolean reportImmediately)
Report a set of new, modified or deleted files. Modifications are checked against a computed checksum on some file attributes to detect any modification. Upon restart, such checksums are not known so that all files will be reported as modified.

Parameters:
reportImmediately - report all files immediately without waiting for the checksum to be stable
Returns:
a list of changes on the files included in the directory

getChecksum

public long getChecksum(File file)
Retrieve the previously computed checksum for a give file.

Parameters:
file - the file to retrieve the checksum
Returns:
the checksum


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.