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
10 * TODO: TEST THIS CLASS - not yet used in SimpleClient
\r
12 public class SessionFlagWatcherElement extends WatcherElement {
\r
13 SessionFlagFile 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 SessionFlagWatcherElement(SessionFlagFile watcher, WatcherCallBack handler) {
\r
20 this(watcher, handler, true);
\r
22 protected void initWatch() {
\r
25 watcher = new FileWatcher(watched.flagFile);
\r
27 protected void endWatch() {
\r
28 // leaves watcher in state its in.
\r
31 * new watcher with flag to initially skip watching this sessionfile
\r
34 * @param enableWatching
\r
36 public SessionFlagWatcherElement(SessionFlagFile watcher, WatcherCallBack handler, boolean enableWatching) {
\r
38 this.watched = watcher;
\r
45 * @return the watched
\r
47 public SessionFlagFile getWatched() {
\r
50 protected String getSubject() {
\r
52 return watched.flagFile.toString();
\r