KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.jpivot.olap.model.impl;
14
15 import java.util.ArrayList JavaDoc;
16 import java.util.Collections JavaDoc;
17 import java.util.List JavaDoc;
18
19 import javax.servlet.ServletContext JavaDoc;
20
21 import com.tonbeller.jpivot.core.ModelSupport;
22 import com.tonbeller.jpivot.olap.model.Axis;
23 import com.tonbeller.jpivot.olap.model.Dimension;
24 import com.tonbeller.jpivot.olap.model.Hierarchy;
25 import com.tonbeller.jpivot.olap.model.Member;
26 import com.tonbeller.jpivot.olap.model.OlapException;
27 import com.tonbeller.jpivot.olap.model.OlapModel;
28 import com.tonbeller.jpivot.olap.model.Result;
29 import com.tonbeller.jpivot.olap.model.Visitor;
30
31 /**
32  * an empty OlapModel that contains no axes and no cells
33  *
34  * @author av
35  * @since 21.04.2005
36  */

37 public class Empty {
38   public static final OlapModel EMPTY_MODEL = new EmptyModel();
39   public static final Result EMPTY_RESULT = new EmptyResult(false);
40   public static final Result OVERFLOW_RESULT = new EmptyResult(true);
41   public static final Axis EMPTY_AXIS = new EmptyAxis();
42
43   private Empty() {
44   }
45
46   public static class EmptyModel extends ModelSupport implements OlapModel {
47     private String JavaDoc ID = null;
48
49     public String JavaDoc getID() {
50       return ID;
51     }
52
53     public void setID(String JavaDoc ID) {
54       this.ID = ID;
55     }
56
57     public Result getResult() throws OlapException {
58       return EMPTY_RESULT;
59     }
60
61     public Dimension[] getDimensions() {
62       return new Dimension[0];
63     }
64
65     public Member[] getMeasures() {
66       return new Member[0];
67     }
68
69     public void initialize() {
70     }
71
72     public void destroy() {
73     }
74
75     public void setServletContext(ServletContext JavaDoc servletContext) {
76     }
77  
78   }
79
80   static class EmptyResult implements Result {
81     static List JavaDoc cells;
82     boolean overflow;
83     public EmptyResult(boolean overflow) {
84       this.overflow = overflow;
85       cells = new ArrayList JavaDoc();
86       //cells.add(new CellImpl());
87
}
88
89     public List JavaDoc getCells() {
90       return cells;
91     }
92
93     public Axis[] getAxes() {
94       return new Axis[0];
95     }
96
97     public Axis getSlicer() {
98       return EMPTY_AXIS;
99     }
100
101     public void accept(Visitor visitor) {
102       visitor.visitResult(this);
103     }
104
105     public Object JavaDoc getRootDecoree() {
106       return this;
107     }
108
109     public boolean isOverflowOccured() {
110       return overflow;
111     }
112   }
113
114   static class EmptyAxis implements Axis {
115     public List JavaDoc getPositions() {
116       return Collections.EMPTY_LIST;
117     }
118
119     public Hierarchy[] getHierarchies() {
120       return new Hierarchy[0];
121     }
122
123     public void accept(Visitor visitor) {
124       visitor.visitAxis(this);
125     }
126
127     public Object JavaDoc getRootDecoree() {
128       return this;
129     }
130   }
131 }
Popular Tags