jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.alert
Class AbstractFileWatcher

java.lang.Object
  extended byuk.co.weft.alert.Watcher
      extended byuk.co.weft.alert.AbstractFileWatcher
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
FileWatcher, URLWatcher

public abstract class AbstractFileWatcher
extends Watcher

An abstract superclass for FileWatcher, URLWatcher and similar.

Since:
Jacquard 1.10 This revision: $Author: simon $
Version:
$Revision: 1.1.4.1 $
Author:
Simon Brooke (simon

Nested Class Summary
protected  class AbstractFileWatcher.FileValues
          an object to pass the observed values of the file through the context
 
Field Summary
static java.lang.String FILETOKEN
          A token on which we will seek the fully qualified pathname of the file to be watched in the config, and on which we will store that pathname in the alert-time context
protected  long lastModified
          when it last changed
protected  long lastSize
          how big it was
static java.lang.String OBSERVEDVALUESTOKEN
          a token on which we will store the observed values in the alert time context
protected  java.lang.String path
          the path to the file I watch
protected  java.io.File watched
          the file I watch
static java.lang.String WHENCHANGEDTOKEN
          a token on which we will store the time when change was noted in the alert time context
 
Fields inherited from class uk.co.weft.alert.Watcher
alerter, alerts, configuration, debug, DEBUGTOKEN, ERRORTOKEN, INTERVALTOKEN, name, NAMETOKEN, recipient, resourceBundleName, sender, subject, SUBJECTTOKEN, template, TEMPLATETOKEN, thread, tooManyErrors, TOOMANYERRORS, whinges, winks
 
Constructor Summary
AbstractFileWatcher()
           
 
Method Summary
 void init(java.util.Map config)
          initialise me with this configuration
protected  boolean mark(java.util.Map details)
          mark the event indicated by details as having had it's alert sent
protected  java.lang.String maybeEscapePath(java.lang.String path)
          Windows pathnames incude backslashes, which are treated by Java printing routines as introducing escape sequences.
 
Methods inherited from class uk.co.weft.alert.Watcher
check, coerceToUrl, getAlerts, getArgs, getName, getNextCheck, getResource, getResourceString, getState, getStringWithDefault, getWhinges, grs, grs, maybeCheck, reset, resetWhinges, run, sendAlert, start, stop, usage, whinge
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILETOKEN

public static final java.lang.String FILETOKEN
A token on which we will seek the fully qualified pathname of the file to be watched in the config, and on which we will store that pathname in the alert-time context

See Also:
Constant Field Values

WHENCHANGEDTOKEN

public static final java.lang.String WHENCHANGEDTOKEN
a token on which we will store the time when change was noted in the alert time context

See Also:
Constant Field Values

OBSERVEDVALUESTOKEN

public static final java.lang.String OBSERVEDVALUESTOKEN
a token on which we will store the observed values in the alert time context

See Also:
Constant Field Values

watched

protected java.io.File watched
the file I watch


path

protected java.lang.String path
the path to the file I watch


lastModified

protected long lastModified
when it last changed


lastSize

protected long lastSize
how big it was

Constructor Detail

AbstractFileWatcher

public AbstractFileWatcher()
Method Detail

init

public void init(java.util.Map config)
          throws AlertingException
initialise me with this configuration

Overrides:
init in class Watcher
Throws:
AlertingException

mark

protected boolean mark(java.util.Map details)
                throws java.lang.Exception
mark the event indicated by details as having had it's alert sent

Overrides:
mark in class Watcher
Parameters:
details - details of the event seen
Returns:
true if alert was despatched successfully (doesn't prove it will be received)
Throws:
java.lang.Exception

maybeEscapePath

protected java.lang.String maybeEscapePath(java.lang.String path)
Windows pathnames incude backslashes, which are treated by Java printing routines as introducing escape sequences. This means they get printed wrong, which makes debugging difficult. This routine tidies such strings up for printing


jacquard 1.12.0 by The Web Engineering Factory and Toolworks