1 package uk.ac.vamsas.client.simpleclient;
\r
5 * Element of the VamsasFileWatcherThread event generator chain.
\r
6 * Keep a reference to this element before adding it to the chain
\r
7 * in order to control the generation of events with halt and enable.
\r
9 * doWatch will do nothing if the element is not enabled.
\r
12 public class SessionFileWatcherElement extends WatcherElement {
\r
13 SessionFile watched=null;
\r
15 * create a new, enabled watch element
\r
16 * @param watcher file being watched
\r
17 * @param handler handler to call on state change
\r
19 public SessionFileWatcherElement(SessionFile watcher, WatcherCallBack handler) {
\r
20 this(watcher, handler, true);
\r
22 protected void initWatch() {
\r
25 if (watcher==null || !watcher.getSubject().equals(watched.sessionFile))
\r
26 watcher=new FileWatcher(watched.sessionFile);
\r
30 protected void endWatch() {
\r
31 // leaves watcher in state its in.
\r
34 * new watcher with flag to initially skip watching this sessionfile
\r
37 * @param enableWatching
\r
39 public SessionFileWatcherElement(SessionFile watcher, WatcherCallBack handler, boolean enableWatching) {
\r
41 this.watched = watcher;
\r
48 * @return the watched
\r
50 public SessionFile getWatched() {
\r
53 protected String getSubject() {
\r
54 return watched.sessionFile.toString();
\r