--- /dev/null
+package uk.ac.vamsas.client.simpleclient;\r
+\r
+\r
+/**\r
+ * Element of the VamsasFileWatcherThread event generator chain.\r
+ * Keep a reference to this element before adding it to the chain \r
+ * in order to control the generation of events with halt and enable.\r
+ * \r
+ * doWatch will do nothing if the element is not enabled.\r
+ * TODO: TEST THIS CLASS - not yet used in SimpleClient\r
+ */\r
+public class SessionFlagWatcherElement extends WatcherElement {\r
+ SessionFlagFile watched=null;\r
+ /**\r
+ * create a new, enabled watch element\r
+ * @param watcher file being watched\r
+ * @param handler handler to call on state change\r
+ */\r
+ public SessionFlagWatcherElement(SessionFlagFile watcher, WatcherCallBack handler) {\r
+ this(watcher, handler, true);\r
+ }\r
+ protected void initWatch() {\r
+ if (watched==null)\r
+ return;\r
+ watcher = new FileWatcher(watched.flagFile);\r
+ }\r
+ protected void endWatch() {\r
+ // leaves watcher in state its in.\r
+ }\r
+ /**\r
+ * new watcher with flag to initially skip watching this sessionfile\r
+ * @param watcher\r
+ * @param handler\r
+ * @param enableWatching\r
+ */\r
+ public SessionFlagWatcherElement(SessionFlagFile watcher, WatcherCallBack handler, boolean enableWatching) {\r
+ super(handler);\r
+ this.watched = watcher;\r
+ if (enableWatching)\r
+ enableWatch();\r
+ else\r
+ haltWatch();\r
+ }\r
+ /**\r
+ * @return the watched\r
+ */\r
+ public SessionFlagFile getWatched() {\r
+ return watched;\r
+ }\r
+ protected String getSubject() {\r
+ \r
+ return watched.flagFile.toString();\r
+ }\r
+}\r