org.abraracourcix.alipes.monitors.file
Class AbstractFileStateMonitor

java.lang.Object
  extended byorg.abraracourcix.alipes.monitors.AbstractMonitor
      extended byorg.abraracourcix.alipes.monitors.PollingMonitor
          extended byorg.abraracourcix.alipes.monitors.file.AbstractFileStateMonitor
All Implemented Interfaces:
Monitor, java.lang.Runnable
Direct Known Subclasses:
DirectoryFileStateMonitor, FileStateMonitor

public abstract class AbstractFileStateMonitor
extends PollingMonitor

Factors out everything we know about FileStateMonitors, leaving subclasses to decide how to manage the files we want to monitor

Author:
jdt

Nested Class Summary
protected static class AbstractFileStateMonitor.FileInfo
          Simply a dataholder we can stick in a map containing info about a file
protected static class AbstractFileStateMonitor.FileState
           
 
Field Summary
static int NEVER
          Hardcoded value to say that files should never be considered stale
 
Constructor Summary
AbstractFileStateMonitor(Listener listener, long pollingFrequency)
          Constructor - pass through to superclass
 
Method Summary
 void addFile(java.io.File file)
          Adds a file with unknown state to the list of files to be monitored
 void addFile(java.io.File file, AbstractFileStateMonitor.FileState state)
          Add a file the list we monitor and set its state to unknown
 void addFiles(java.io.File[] files)
          Add files to the list we monitor and set their state to unknown
protected  void checkTheFiles()
          Check the file list and respond acccordingly (non-Javadoc) @TODO deal with exception properly
protected  java.util.Set getMonitoredFiles()
          Get a collection of the files we're monitoring
 int getStaleInterval()
          Stale interval in seconds
 void setStaleInterval(int staleInterval)
          Stale interval in seconds - the time after which the file goes stale use setStaleInterval(FileStateMonitor.NEVER) if the files are never considered stale.
 
Methods inherited from class org.abraracourcix.alipes.monitors.PollingMonitor
getPollingFrequency, pole, run, setPollingFrequency, start
 
Methods inherited from class org.abraracourcix.alipes.monitors.AbstractMonitor
signalListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEVER

public static final int NEVER
Hardcoded value to say that files should never be considered stale

See Also:
Constant Field Values
Constructor Detail

AbstractFileStateMonitor

public AbstractFileStateMonitor(Listener listener,
                                long pollingFrequency)
Constructor - pass through to superclass

Parameters:
listener - see superclass
pollingFrequency - see superclass
Method Detail

getStaleInterval

public final int getStaleInterval()
Stale interval in seconds

Returns:
Returns the staleIntervalMillis.

setStaleInterval

public final void setStaleInterval(int staleInterval)
Stale interval in seconds - the time after which the file goes stale use setStaleInterval(FileStateMonitor.NEVER) if the files are never considered stale.

Parameters:
staleInterval - The staleIntervalMillis to set.

addFile

public final void addFile(java.io.File file,
                          AbstractFileStateMonitor.FileState state)
Add a file the list we monitor and set its state to unknown

Parameters:
file - another file
state - the initial state of the file added

checkTheFiles

protected final void checkTheFiles()
Check the file list and respond acccordingly (non-Javadoc) @TODO deal with exception properly


addFiles

public final void addFiles(java.io.File[] files)
Add files to the list we monitor and set their state to unknown

Parameters:
files - the files to add

addFile

public final void addFile(java.io.File file)
Adds a file with unknown state to the list of files to be monitored

Parameters:
file - the file

getMonitoredFiles

protected final java.util.Set getMonitoredFiles()
Get a collection of the files we're monitoring

Returns:
sais files


Copyright © 2004-2005 Abraracourcix. All Rights Reserved.