KickJava   Java API By Example, From Geeks To Geeks.

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


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

27 public class MondrianHierarchy implements Hierarchy, MDXElement {
28
29    private mondrian.olap.Hierarchy monHierarchy;
30    private MondrianDimension dimension;
31    private ArrayList JavaDoc aLevels;
32    private MondrianModel model;
33    private Resources resources;
34    
35    /**
36     * Constructor
37     * @param monHierarchy Mondrian Hierarchy
38     * @param dimension parent
39     */

40    protected MondrianHierarchy( mondrian.olap.Hierarchy monHierarchy,
41                                  MondrianDimension dimension, MondrianModel model ) {
42       this.monHierarchy = monHierarchy;
43       this.dimension = dimension;
44       this.model = model;
45       this.resources = Resources.instance(model.getLocale(), MondrianHierarchy.class);
46       aLevels = new ArrayList JavaDoc();
47       dimension.addHierarchy(this);
48    }
49    
50    /**
51     * add level
52     * @param level MondrianLevel
53     */

54    protected void addLevel(MondrianLevel level) {
55       aLevels.add(level);
56    }
57
58
59     /**
60      * @see com.tonbeller.jpivot.olap.model.Hierarchy#getDimension()
61      */

62     public Dimension getDimension() {
63         return dimension;
64     }
65
66     /**
67      * @see com.tonbeller.jpivot.olap.model.Hierarchy#getLevels()
68      */

69     public Level[] getLevels() {
70         return (Level[]) aLevels.toArray( new MondrianLevel[0] );
71     }
72
73    public String JavaDoc getLabel() {
74      String JavaDoc label = monHierarchy.getCaption();
75      return resources.getOptionalString(label, label);
76    }
77
78   /**
79    * @see com.tonbeller.jpivot.olap.model.Visitable#accept(Visitor)
80    */

81   public void accept(Visitor visitor) {
82     visitor.visitHierarchy(this);
83   }
84
85     /**
86      * Returns the monHierarchy.
87      * @return mondrian.olap.Hierarchy
88      */

89     public mondrian.olap.Hierarchy getMonHierarchy() {
90         return monHierarchy;
91     }
92   
93   public Object JavaDoc getRootDecoree() {
94     return this;
95   }
96
97     /**
98    * @return the unique name
99      * @see com.tonbeller.jpivot.olap.model.Hierarchy#getUniqueName()
100      */

101     public String JavaDoc getUniqueName() {
102         return monHierarchy.getUniqueName();
103     }
104   public boolean hasAll() {
105      return monHierarchy.hasAll();
106   }
107 }
108
Popular Tags