KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > olap > model > impl > ProtozoanOlapModel


1 package com.tonbeller.jpivot.olap.model.impl;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 import org.apache.log4j.Logger;
7
8 import com.tonbeller.jpivot.core.ModelChangeListener;
9 import com.tonbeller.jpivot.olap.model.OlapException;
10 import com.tonbeller.jpivot.olap.model.OlapModel;
11
12 public class ProtozoanOlapModel extends ScalarOlapModel {
13   private static final CellImpl ERROR_CELL = new CellImpl();
14   static {
15     ERROR_CELL.setFormattedValue("splitQuery: Index not found");
16     ERROR_CELL.setValue(new Double JavaDoc(Double.NaN));
17   }
18
19   private OlapModel realModel;
20   private int idx;
21
22   private static Logger logger = Logger.getLogger(ProtozoanOlapModel.class);
23
24   public ProtozoanOlapModel(OlapModel om, int idx) {
25     super();
26     this.realModel = om;
27     this.idx = idx;
28   }
29
30   public void addModelChangeListener(ModelChangeListener l) {
31     realModel.addModelChangeListener(l);
32   }
33
34   public void removeModelChangeListener(ModelChangeListener l) {
35     realModel.removeModelChangeListener(l);
36   }
37
38   public List JavaDoc getCells() {
39     List JavaDoc l = null;
40     try {
41       l = realModel.getResult().getCells();
42     } catch (OlapException e) {
43       logger.error(null, e);
44     }
45     if (l == null) return null;
46
47     List JavaDoc ret = new ArrayList JavaDoc();
48     if(l.size() > idx) {
49       ret.add(l.get(idx));
50     } else {
51       ret.add(ERROR_CELL);
52       System.out.println("Index " + idx + " not in cell-list");
53       logger.error("Index " + idx + " not in cell-list");
54     }
55     return ret;
56   }
57 }
58
Popular Tags