KickJava   Java API By Example, From Geeks To Geeks.

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


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.List JavaDoc;
17
18 import com.tonbeller.jpivot.olap.model.Axis;
19 import com.tonbeller.jpivot.olap.model.Hierarchy;
20 import com.tonbeller.jpivot.olap.model.Member;
21 import com.tonbeller.jpivot.olap.model.Position;
22 import com.tonbeller.jpivot.olap.model.Visitor;
23
24 /**
25  * implements axis
26  * @author av
27  */

28 public class AxisImpl implements Axis {
29
30   List JavaDoc positions = new ArrayList JavaDoc();
31
32   /**
33    * @return the hierarchies of the members of the first position.
34    * If there are no positions (i.e. axis is empty), an empty array (non null)
35    * is returned.
36    * @see com.tonbeller.jpivot.olap.model.Axis#getHierarchies()
37    */

38   public Hierarchy[] getHierarchies() {
39     if (positions.size() > 0) {
40       Position pos = (Position)positions.get(0);
41       Member[] members = pos.getMembers();
42       Hierarchy[] hiers = new Hierarchy[members.length];
43       for (int i = 0; i < members.length; i++)
44         hiers[i] = members[i].getLevel().getHierarchy();
45       return hiers;
46     }
47     return new Hierarchy[0];
48   }
49
50   /**
51    * Returns the positions.
52    * @return List
53    */

54   public List JavaDoc getPositions() {
55     return positions;
56   }
57
58   /**
59    * Sets the positions.
60    * @param positions The positions to set
61    */

62   public void setPositions(List JavaDoc positions) {
63     this.positions = positions;
64   }
65
66   public void addPosition(Position pos) {
67     positions.add(pos);
68   }
69
70   public void accept(Visitor visitor) {
71     visitor.visitAxis(this);
72   }
73   
74   public Object JavaDoc getRootDecoree() {
75     return this;
76   }
77
78 }
79
Popular Tags