KickJava   Java API By Example, From Geeks To Geeks.

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


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.Hierarchy;
18 import com.tonbeller.jpivot.olap.model.Level;
19 import com.tonbeller.jpivot.olap.model.Visitor;
20 import com.tonbeller.jpivot.olap.query.MDXElement;
21 import com.tonbeller.jpivot.olap.query.MDXLevel;
22 import com.tonbeller.tbutils.res.Resources;
23
24 /**
25  * Level implementation for Mondrian.
26  * MondrianLevel is an adapter class for the Mondrian Level.
27  */

28 public class MondrianLevel implements Level, MDXElement, MDXLevel {
29
30   private mondrian.olap.Level monLevel;
31   private MondrianHierarchy hierarchy;
32   private ArrayList JavaDoc aMembers;
33   private MondrianModel model;
34   private Resources resources;
35
36   /**
37    * Constructor
38    * @param monLevel corresponding Mondrian Level
39    * @param hierarchy parent object
40    * @param model Model
41    */

42   protected MondrianLevel(
43     mondrian.olap.Level monLevel,
44     MondrianHierarchy hierarchy,
45     MondrianModel model) {
46     this.monLevel = monLevel;
47     this.hierarchy = hierarchy;
48     this.model = model;
49     this.resources = Resources.instance(model.getLocale(), MondrianLevel.class);
50     aMembers = new ArrayList JavaDoc();
51     hierarchy.addLevel(this);
52   }
53
54   /**
55    * add member to level
56    * @param members Array of MondrianMember
57    */

58   protected void addMember(MondrianMember member) {
59     aMembers.add(member);
60   }
61
62   /**
63    * @see com.tonbeller.jpivot.olap.model.Level#getHierarchy()
64    */

65   public Hierarchy getHierarchy() {
66     return hierarchy;
67   }
68
69   public String JavaDoc getLabel() {
70     String JavaDoc label = monLevel.getCaption();
71     return resources.getOptionalString(label, label);
72   }
73
74   /**
75    * @return the level's depth (root level = 0)
76    * @see com.tonbeller.jpivot.olap.query.MDXLevel#getDepth()
77    */

78   public int getDepth() {
79     return monLevel.getDepth();
80   }
81
82   /**
83    * @see com.tonbeller.jpivot.olap.model.Visitable#accept(Visitor)
84    */

85   public void accept(Visitor visitor) {
86     visitor.visitLevel(this);
87   }
88
89   public Object JavaDoc getRootDecoree() {
90     return this;
91   }
92
93   /**
94    * @return the assigned Mondrian Level
95    */

96   public mondrian.olap.Level getMonLevel() {
97     return monLevel;
98   }
99
100   /**
101    * @return the level's unique name
102    */

103   public String JavaDoc getUniqueName() {
104     return monLevel.getUniqueName();
105   }
106
107   /**
108    * @see com.tonbeller.jpivot.olap.query.MDXLevel#isAll()
109    */

110   public boolean isAll() {
111     return monLevel.isAll();
112   }
113
114   /**
115    * @see com.tonbeller.jpivot.olap.query.MDXLevel#hasChildLevel()
116    */

117   public boolean hasChildLevel() {
118     return (monLevel.getChildLevel() != null);
119   }
120
121 } // MondrianLevel
122
Popular Tags