KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > common > StaticReportResult


1 package com.calipso.reportgenerator.common;
2
3 import com.calipso.reportgenerator.reportcalculator.*;
4
5 import java.util.*;
6
7 /**
8  *
9  * User: soliveri
10  * Date: Dec 16, 2003
11  * Time: 2:13:10 PM
12  *
13  */

14
15 public class StaticReportResult extends ReportResult {
16
17   private DataTree dataTree;
18   private ReportTableModel reportTable = null;
19
20   public StaticReportResult(ReportSpec reportSpec, ReportQuery reportQuery, DataTree dataTree) {
21     super(reportSpec, reportQuery);
22     this.dataTree = dataTree;
23   }
24
25   public DataTree getDataTree() {
26     return dataTree;
27   }
28
29   public ReportTableModel getReportTableModel() throws InfoException {
30     if(reportTable==null){
31         reportTable = new StaticReportTableModel(this);
32     }
33     return reportTable;
34   }
35
36   public void resetReportTableModel(){
37       reportTable = null;
38   }
39
40   public Collection getValuesCollection(boolean ascending) {
41     TreeMap set = new TreeMap(getComparator(ascending));
42     Iterator iterator = getDataTree().getRoot().getSubNodes().entrySet().iterator();
43     while (iterator.hasNext()) {
44       Map.Entry entry = (Map.Entry)iterator.next();
45       DataTreeNode node = (DataTreeNode)entry.getValue();
46       set.put(node.getMetrics()[0], entry);
47     }
48     return set.entrySet();
49   }
50
51   private Comparator getComparator(boolean ascending) {
52     if(ascending){
53       return new Comparator(){
54                   public int compare(Object JavaDoc o1, Object JavaDoc o2){
55                     return ((SharedFloat)o1).compareTo(o2);
56                   }
57                 };
58     }else{
59       return new Comparator(){
60                   public int compare(Object JavaDoc o1, Object JavaDoc o2){
61                     return -((SharedFloat)o1).compareTo(o2);
62                   }
63                 };
64     }
65   }
66
67   public ReportSpec getReportSpec() {
68     return super.getReportSpec();
69   }
70
71   public ReportQuery getReportQuery() {
72     return super.getReportQuery();
73   }
74
75 }
76
Popular Tags