merge of localization branch into HEAD. mh and zap
[mir.git] / source / mir / util / FileMonitor.java
1 package mir.util;
2
3 import java.util.*;
4 import java.io.*;
5
6 public class FileMonitor {
7   private Map files;
8
9   public FileMonitor() {
10     files = new HashMap();
11   }
12
13   public void addFile(File aFile) {
14     files.put(aFile, new Long(aFile.lastModified()));
15   }
16
17   public void clear() {
18     files.clear();
19   }
20
21   public boolean hasChanged() {
22     Iterator i = files.entrySet().iterator();
23
24     while (i.hasNext()) {
25       Map.Entry entry = (Map.Entry) i.next();
26       File file = (File) entry.getKey();
27       Long lastModified = (Long) entry.getValue();
28
29       if (lastModified.longValue()!=file.lastModified())
30         return true;
31     }
32
33     return false;
34   }
35 }