KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > xmla > XMLA_Dimension


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.xmla;
14
15 import java.util.ArrayList JavaDoc;
16 import java.util.HashMap JavaDoc;
17 import java.util.Map JavaDoc;
18
19 import com.tonbeller.jpivot.olap.mdxparse.CompoundId;
20 import com.tonbeller.jpivot.olap.mdxparse.Exp;
21 import com.tonbeller.jpivot.olap.mdxparse.ExpVisitor;
22 import com.tonbeller.jpivot.olap.model.Dimension;
23 import com.tonbeller.jpivot.olap.model.Hierarchy;
24 import com.tonbeller.jpivot.olap.model.Visitor;
25 import com.tonbeller.jpivot.olap.query.MDXElement;
26
27 /**
28  * XMLA Dimension
29  */

30 public class XMLA_Dimension implements Dimension, Exp, MDXElement {
31
32   private String JavaDoc name;
33   private String JavaDoc uniqueName;
34   private String JavaDoc caption;
35   private int ordinal;
36   private int type;
37   private int cardinality;
38   private String JavaDoc defaultHier;
39   private boolean isVirtual;
40   private boolean isReadWrite;
41   private int uniqueSettings;
42   private boolean isVisible;
43   private String JavaDoc description;
44
45   private ArrayList JavaDoc aHierarchies = new ArrayList JavaDoc();
46
47   private Map JavaDoc props = new HashMap JavaDoc(); // member properties , SAP
48

49   // dimension types (not documented?)
50
public static final int MD_DIMTYPE_TIME = 1;
51   public static final int MD_DIMTYPE_MEASURE = 2;
52   public static final int MD_DIMTYPE_OTHER = 3;
53
54   /**
55    * @see com.tonbeller.jpivot.olap.model.Dimension#isMeasure()
56    */

57   public boolean isMeasure() {
58     return type == MD_DIMTYPE_MEASURE;
59   }
60
61   /**
62    * @see com.tonbeller.jpivot.olap.model.Dimension#isTime()
63    */

64   public boolean isTime() {
65     return type == MD_DIMTYPE_TIME;
66   }
67
68   public String JavaDoc getLabel() {
69     return caption;
70   }
71
72   /**
73    * @see com.tonbeller.jpivot.olap.model.Dimension#getHierarchies()
74    */

75   public Hierarchy[] getHierarchies() {
76     return (Hierarchy[]) aHierarchies.toArray(new XMLA_Hierarchy[0]);
77   }
78
79   /**
80    * @see com.tonbeller.jpivot.olap.model.Visitable#accept(Visitor)
81    */

82   public void accept(Visitor visitor) {
83     visitor.visitDimension(this);
84   }
85
86   public Object JavaDoc getRootDecoree() {
87     return this;
88   }
89
90   /**
91    * Returns the caption.
92    * @return String
93    */

94   public String JavaDoc getCaption() {
95     return caption;
96   }
97
98   /**
99    * Returns the cardinality.
100    * @return int
101    */

102   public int getCardinality() {
103     return cardinality;
104   }
105
106   /**
107    * Returns the defaultHier.
108    * @return String
109    */

110   public String JavaDoc getDefaultHier() {
111     return defaultHier;
112   }
113
114   /**
115    * Returns the isReadWrite.
116    * @return boolean
117    */

118   public boolean isReadWrite() {
119     return isReadWrite;
120   }
121
122   /**
123    * Returns the isVirtual.
124    * @return boolean
125    */

126   public boolean isVirtual() {
127     return isVirtual;
128   }
129
130   /**
131    * Returns the isVisible.
132    * @return boolean
133    */

134   public boolean isVisible() {
135     return isVisible;
136   }
137
138   /**
139    * Returns the name.
140    * @return String
141    */

142   public String JavaDoc getName() {
143     return name;
144   }
145
146   /**
147    * Returns the ordinal.
148    * @return int
149    */

150   public int getOrdinal() {
151     return ordinal;
152   }
153
154   /**
155    * Returns the type.
156    * @return int
157    */

158   public int getType() {
159     return type;
160   }
161
162   /**
163    * Returns the uniqueName.
164    * @return String
165    */

166   public String JavaDoc getUniqueName() {
167     return uniqueName;
168   }
169
170   /**
171    * Returns the uniqueSettings.
172    * @return int
173    */

174   public int getUniqueSettings() {
175     return uniqueSettings;
176   }
177
178   /**
179    * Sets the caption.
180    * @param caption The caption to set
181    */

182   public void setCaption(String JavaDoc caption) {
183     this.caption = caption;
184   }
185
186   /**
187    * Sets the cardinality.
188    * @param cardinality The cardinality to set
189    */

190   public void setCardinality(int cardinality) {
191     this.cardinality = cardinality;
192   }
193
194   /**
195    * Sets the defaultHier.
196    * @param defaultHier The defaultHier to set
197    */

198   public void setDefaultHier(String JavaDoc defaultHier) {
199     this.defaultHier = defaultHier;
200   }
201
202   /**
203    * Sets the isReadWrite.
204    * @param isReadWrite The isReadWrite to set
205    */

206   public void setReadWrite(boolean isReadWrite) {
207     this.isReadWrite = isReadWrite;
208   }
209
210   /**
211    * Sets the isVirtual.
212    * @param isVirtual The isVirtual to set
213    */

214   public void setVirtual(boolean isVirtual) {
215     this.isVirtual = isVirtual;
216   }
217
218   /**
219    * Sets the isVisible.
220    * @param isVisible The isVisible to set
221    */

222   public void setVisible(boolean isVisible) {
223     this.isVisible = isVisible;
224   }
225
226   /**
227    * Sets the name.
228    * @param name The name to set
229    */

230   public void setName(String JavaDoc name) {
231     this.name = name;
232   }
233
234   /**
235    * Sets the ordinal.
236    * @param ordinal The ordinal to set
237    */

238   public void setOrdinal(int ordinal) {
239     this.ordinal = ordinal;
240   }
241
242   /**
243    * Sets the type.
244    * @param type The type to set
245    */

246   public void setType(int type) {
247     this.type = type;
248   }
249
250   /**
251    * Sets the uniqueName.
252    * @param uniqueName The uniqueName to set
253    */

254   public void setUniqueName(String JavaDoc uniqueName) {
255     this.uniqueName = uniqueName;
256   }
257
258   /**
259    * Sets the uniqueSettings.
260    * @param uniqueSettings The uniqueSettings to set
261    */

262   public void setUniqueSettings(int uniqueSettings) {
263     this.uniqueSettings = uniqueSettings;
264   }
265
266   /**
267    * add hierarchy for this dimension
268    * @param hier
269    */

270   public void addHier(Hierarchy hier) {
271     aHierarchies.add(hier);
272   }
273
274   /**
275     * @return the unique name
276     * @see com.tonbeller.jpivot.olap.mdxparse.Exp#toMdx()
277     */

278   public String JavaDoc toMdx() {
279     return uniqueName;
280   }
281
282   /**
283    * @see com.tonbeller.jpivot.olap.mdxparse.Exp#clone()
284    * probably not needed
285    */

286   public Object JavaDoc clone() {
287     String JavaDoc str = uniqueName.substring(1, uniqueName.length() - 1);
288     String JavaDoc[] nameParts = new String JavaDoc[] { str };
289
290     CompoundId clone = new CompoundId(nameParts[0], false);
291     return clone;
292   }
293
294   /**
295     * @return
296     */

297   public Map JavaDoc getProps() {
298     return props;
299   }
300
301   /**
302    * add a property
303    */

304   public void addProp(XMLA_MemberProp prop) {
305     if (!props.containsKey(prop.getXmlTag())) {
306       props.put(prop.getXmlTag(), prop);
307     }
308   }
309
310   /**
311    * retrieve a property
312    */

313   public XMLA_MemberProp getProp(String JavaDoc xmlTag) {
314     return (XMLA_MemberProp) props.get(xmlTag);
315   }
316
317   /**
318    * @see com.tonbeller.jpivot.olap.mdxparse.Exp#accept
319    */

320   public void accept(ExpVisitor visitor) {
321     visitor.visitDimension(this);
322   }
323
324 } // XMLA_Dimension
325
Popular Tags