KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > mondrian > MondrianDimension


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.mondrian;
14
15 import java.util.ArrayList JavaDoc;
16
17 import com.tonbeller.jpivot.olap.model.Dimension;
18 import com.tonbeller.jpivot.olap.model.Hierarchy;
19 import com.tonbeller.jpivot.olap.model.Visitor;
20 import com.tonbeller.jpivot.olap.query.MDXElement;
21 import com.tonbeller.tbutils.res.Resources;
22
23 /**
24  * MondrianDimension is an adapter class for the Mondrian Dimension.
25  */

26 public class MondrianDimension implements Dimension, MDXElement {
27
28   private mondrian.olap.Dimension monDimension = null;
29   private ArrayList JavaDoc aHierarchies;
30   MondrianModel model;
31   Resources resources;
32
33   protected MondrianDimension(mondrian.olap.Dimension monDimension, MondrianModel model) {
34     this.monDimension = monDimension;
35     this.model = model;
36     aHierarchies = new ArrayList JavaDoc();
37     resources = Resources.instance(model.getLocale(), MondrianDimension.class);
38   }
39
40   /**
41    * add Hierarchy
42    * @param hierarchy MondrianHierarchy to be stored
43    */

44   protected void addHierarchy(MondrianHierarchy hierarchy) {
45     aHierarchies.add(hierarchy);
46   }
47
48   /**
49    * @see com.tonbeller.jpivot.olap.model.Dimension#getHierarchies()
50    */

51   public Hierarchy[] getHierarchies() {
52     return (Hierarchy[]) aHierarchies.toArray(new MondrianHierarchy[0]);
53   }
54
55   /**
56    * @see com.tonbeller.jpivot.olap.model.Dimension#isTime()
57    */

58   public boolean isTime() {
59     return monDimension.getDimensionType() == mondrian.olap.DimensionType.TimeDimension;
60   }
61
62   /**
63    * @see com.tonbeller.jpivot.olap.model.Dimension#isMeasure()
64    */

65   public boolean isMeasure() {
66     return monDimension.isMeasures();
67   }
68
69   public String JavaDoc getLabel() {
70     String JavaDoc label = monDimension.getCaption();
71     return resources.getOptionalString(label, label);
72   }
73
74   /**
75    * @see com.tonbeller.jpivot.olap.model.Visitable#accept(Visitor)
76    */

77   public void accept(Visitor visitor) {
78     visitor.visitDimension(this);
79   }
80
81   public Object JavaDoc getRootDecoree() {
82     return this;
83   }
84
85     /**
86    * @return the unique name
87      * @see com.tonbeller.jpivot.olap.model.Dimension#getUniqueName()
88      */

89     public String JavaDoc getUniqueName() {
90         return monDimension.getUniqueName();
91     }
92
93     /**
94      * @return the corresponding Mondrian dimension
95      */

96     public mondrian.olap.Dimension getMonDimension() {
97         return monDimension;
98     }
99
100 } // MondrianDimension
101
Popular Tags