## org.mortbay.util
Class Scanner

    java.lang.Object
      org.mortbay.util.Scanner

    public class Scanner

extends Object

Scanner Utility for scanning a directory for added, removed and changed files and reporting these events via registered Listeners. TODO AbstractLifeCycle

Nested Class Summary
`static interface` `Scanner.BulkListener`
`static interface` `Scanner.DiscreteListener`
`static interface` `Scanner.Listener` Listener Marker for notifications re file changes.

Constructor Summary
`Scanner()`

Method Summary
`void` `addListener(Scanner.Listener listener)` Add an added/removed/changed listener
`FilenameFilter` `getFilenameFilter()` Get any filter applied to files in the scan dir.
`boolean` `getRecursive()`
`File` `getScanDir()` Deprecated. use getScanDirs() instead
`List` `getScanDirs()`
`int` `getScanInterval()` Get the scan interval
`Timer` `newTimer()`
`TimerTask` `newTimerTask()`
`void` `removeListener(Scanner.Listener listener)` Remove a registered listener
`void` `reportDifferences(Map currentScan, Map oldScan)` Report the adds/changes/removes to the registered listeners
`void` `scan()` Perform a pass of the scanner and report changes
`Map` `scanFiles()` Recursively scan all files in the designated directories.
`void` `schedule(Timer timer, TimerTask task)`
`void` `setFilenameFilter(FilenameFilter filter)` Apply a filter to files found in the scan directory.
`void` `setRecursive(boolean recursive)`
`void` `setReportExistingFilesOnStartup(boolean reportExisting)` Whether or not an initial scan will report all files as being added.
`void` `setScanDir(File dir)` Deprecated. use setScanDirs(List dirs) instead
`void` `setScanDirs(List dirs)`
`void` `setScanInterval(int scanInterval)` Set the scan interval
`void` `start()` Start the scanning action.
`void` `stop()` Stop the scanning.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Scanner

    public Scanner()

Method Detail

### getScanInterval

    public int getScanInterval()

  Get the scan interval

  Returns:
    interval between scans in seconds

### setScanInterval

    public void setScanInterval(int scanInterval)

  Set the scan interval

  Parameters:
    `scanInterval` - pause between scans in seconds

### setScanDir

    public void setScanDir(File dir)

  Deprecated. use setScanDirs(List dirs) instead

  Set the location of the directory to scan.

  Parameters:
    `dir` -

### getScanDir

    public File getScanDir()

  Deprecated. use getScanDirs() instead

  Get the location of the directory to scan

  Returns:

### setScanDirs

    public void setScanDirs(List dirs)

### getScanDirs

    public List getScanDirs()

### setRecursive

    public void setRecursive(boolean recursive)

### getRecursive

    public boolean getRecursive()

### setFilenameFilter

    public void setFilenameFilter(FilenameFilter filter)

  Apply a filter to files found in the scan directory. Only files matching the filter will be reported as added/changed/removed.

  Parameters:
    `filter` -

### getFilenameFilter

    public FilenameFilter getFilenameFilter()

  Get any filter applied to files in the scan dir.

  Returns:

### setReportExistingFilesOnStartup

    public void setReportExistingFilesOnStartup(boolean reportExisting)

  Whether or not an initial scan will report all files as being added.

  Parameters:
    `reportExisting` - if true, all files found on initial scan will be reported as being added, otherwise not

### addListener

    public void addListener(Scanner.Listener listener)

  Add an added/removed/changed listener

  Parameters:
    `listener` -

### removeListener

    public void removeListener(Scanner.Listener listener)

  Remove a registered listener

  Parameters:
    `listener` - the Listener to be removed

### start

    public void start()

  Start the scanning action.

### newTimerTask

    public TimerTask newTimerTask()

### newTimer

    public Timer newTimer()

### schedule

    public void schedule(Timer timer,
                         TimerTask task)

### stop

    public void stop()

  Stop the scanning.

### scan

    public void scan()

  Perform a pass of the scanner and report changes

### scanFiles

    public Map scanFiles()

  Recursively scan all files in the designated directories.

  Returns:
    Map of name of file to last modified time

### reportDifferences

    public void reportDifferences(Map currentScan,
                                  Map oldScan)

  Report the adds/changes/removes to the registered listeners

  Parameters:
    `currentScan` - the info from the most recent pass
    `oldScan` - info from the previous pass

Copyright © 2008 Mort Bay Consulting. All Rights Reserved.