Normand Briere
2018-07-07 e416acb9b012b17d1efe49ad2199ea7132d874d1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package timeflow.data.analysis;
 
import java.sql.Date;
 
import timeflow.data.analysis.DBAnalysis.*;
import timeflow.data.db.*;
import timeflow.data.db.filter.*;
import timeflow.data.time.RoughTime;
 
public class RangeDateAnalysis implements FieldAnalysis {
 
   String[] description;
   
   @Override
   public String getName() {
       return "Date Range";
   }
 
   @Override
   public String[] getResultDescription() {
       return description;
   }
 
   @Override
   public InterestLevel perform(ActList acts, Field field) {
       long low=0;
       long high=0;
 
       boolean defined=false;
       for (Act a: acts)
       {
           if (a.get(field)==null)
               continue;
           long x=a.getTime(field).getTime();
           if (defined)
           {
               low=Math.min(low,x);
               high=Math.max(high, x);
           } else
           {
               defined=true;
               low=x;
               high=low;
           }
       }
       if (defined)
           description= new String[]
             {
                 "Lowest value: "+new Date(low),
                 "Highest value: "+new Date(high),
             };
       else
           description=new String[] {"No values defined."};
       
       return InterestLevel.INTERESTING;
   }
 
   @Override
   public boolean canHandleType(Class type) {
       return type==RoughTime.class;
   }
}