KickJava   Java API By Example, From Geeks To Geeks.

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


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 /*
14  * Created on 12.06.2003
15  * by hh
16  */

17 package com.tonbeller.jpivot.mondrian;
18
19 /**
20  * Position wrapper for sort
21  * @author hh
22  */

23 public class MondrianSortPosition implements Comparable JavaDoc {
24
25   public int index;
26   private mondrian.olap.Member[] posMembers;
27
28   /** c'tor
29    */

30   public MondrianSortPosition(int index, mondrian.olap.Member[] posMembers) {
31     this.index = index;
32     this.posMembers = posMembers;
33   }
34
35   /**
36    * comparison
37    */

38   public int compareTo(Object JavaDoc o) {
39     MondrianSortPosition other = (MondrianSortPosition)o;
40     DimensionLoop : for (int i = 0; i < this.posMembers.length; i++) {
41       mondrian.olap.Member m1 = this.posMembers[i];
42       mondrian.olap.Member m2 = other.posMembers[i];
43       if (m1.equals(m2))
44         continue DimensionLoop;
45
46       // only compare by unique name,
47
// as this contains the member hierarchy up to the top level
48
int ic = m1.getUniqueName().compareTo(m2.getUniqueName());
49       if (ic != 0)
50         return ic;
51       // everything equal up to here
52
} // DimensionLoop
53

54     return 0; // equal positions, should not occur
55
}
56
57 } // End MondrianSortPosition
58
Popular Tags