4 package org.vamsas.client.simpleclient;
8 import org.vamsas.client.SimpleClient;
11 * @author jim Watches a particular file for its creation, deletion, or
14 public class FileWatcher {
16 private File subject = null;
18 private long lastStat;
20 boolean exists = false;
23 * Make a watcher for a particular file. If the file doesn't exist, the
24 * watcher will watch for its creation (and indicate a change of state)
25 * For locked files, the removal of a lock constitutes a change of
26 * state if the file was modified.
30 private boolean checkLock() {
32 Lock tl = new Lock(subject);
42 private boolean check() {
43 if (subject != null) {
44 if (!subject.exists()) {
52 long newStat = subject.lastModified();
53 if (exists && ((lastStat == newStat) || checkLock())) {
64 public FileWatcher(File subject) {
65 // TODO Auto-generated constructor stub
66 this.subject = subject;
70 public boolean hasChanged() {