KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > test > olap > TestSortRank


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.test.olap;
14
15 import java.util.Arrays JavaDoc;
16
17 import com.tonbeller.jpivot.olap.model.Axis;
18 import com.tonbeller.jpivot.olap.model.Member;
19 import com.tonbeller.jpivot.olap.model.Position;
20 import com.tonbeller.jpivot.olap.navi.SortRank;
21
22 /**
23  * Created on 24.10.2002
24  *
25  * @author av
26  */

27 public class TestSortRank extends TestExtensionSupport implements SortRank {
28   Position sortPosition;
29   int sortMode = SortRank.ASC;
30   int topBottomCount = 10;
31   boolean sorting = true;
32
33   /**
34    * returns true, if one of the members is a measure
35    */

36   public boolean isSortable(Position position) {
37     Member[] members = position.getMembers();
38     for (int i = 0; i < members.length; i++)
39       if (members[i].getLevel().getHierarchy().getDimension().isMeasure())
40         return true;
41     return false;
42   }
43
44   /**
45    * @see com.tonbeller.jpivot.olap.navi.SortRank#isCurrentSorting(Position)
46    */

47   public boolean isCurrentSorting(Position position) {
48     if (sortPosition == null) // no current sort position
49
return false;
50     return Arrays.equals(sortPosition.getMembers(), position.getMembers());
51   }
52
53   /**
54    * @see com.tonbeller.jpivot.olap.navi.SortRank#sort(Axis, Position)
55    */

56   public void sort(Axis membersToSort, Position position) {
57     sortPosition = position;
58     fireModelChanged();
59   }
60
61   /**
62    * Returns the sortMode.
63    * @return int
64    */

65   public int getSortMode() {
66     return sortMode;
67   }
68
69   /**
70    * Returns the topBottomCount.
71    * @return int
72    */

73   public int getTopBottomCount() {
74     return topBottomCount;
75   }
76
77   /**
78    * Sets the sortMode.
79    * @param sortMode The sortMode to set
80    */

81   public void setSortMode(int sortMode) {
82     this.sortMode = sortMode;
83     fireModelChanged();
84   }
85
86   /**
87    * Sets the topBottomCount.
88    * @param topBottomCount The topBottomCount to set
89    */

90   public void setTopBottomCount(int topBottomCount) {
91     this.topBottomCount = topBottomCount;
92     fireModelChanged();
93   }
94
95   public boolean isSorting() {
96     return sorting;
97   }
98
99   /**
100    * Sets the enabled.
101    * @param enabled The enabled to set
102    */

103   public void setSorting(boolean sorting) {
104     this.sorting = sorting;
105     fireModelChanged();
106   }
107
108 }
109
Popular Tags