KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.tonbeller.jpivot.olap.model.Member;
16 import com.tonbeller.jpivot.olap.model.impl.PositionImpl;
17
18 /**
19  * Created on 02.12.2002
20  *
21  * @author av
22  */

23 public class TestPosition extends PositionImpl {
24   TestAxis axis;
25   public TestPosition(TestAxis axis) {
26     this.axis = axis;
27   }
28   /**
29    * Returns the axis.
30    * @return TestAxis
31    */

32   public TestAxis getAxis() {
33     return axis;
34   }
35
36   /**
37    * Sets the axis.
38    * @param axis The axis to set
39    */

40   public void setAxis(TestAxis axis) {
41     this.axis = axis;
42   }
43
44   public boolean contains(Member m) {
45     Member[] members = super.getMembers();
46     for (int i = 0; i < members.length; i++)
47       if (m.equals(members[i]))
48         return true;
49     return false;
50   }
51
52   public boolean membersEqual(TestPosition that) {
53     Member[] m1 = this.getMembers();
54     Member[] m2 = that.getMembers();
55     if (m1.length != m2.length)
56       return false;
57     for (int i = 0; i < m1.length; i++)
58       if (!m1[i].equals(m2[i]))
59         return false;
60     return true;
61   }
62   
63   public int indexOf(Member m) {
64     Member[] members = super.getMembers();
65     for (int i = 0; i < members.length; i++)
66       if (m.equals(members[i]))
67         return i;
68     return -1;
69   }
70
71   public Object JavaDoc clone() {
72     try {
73       TestPosition p = (TestPosition)super.clone();
74       p.setMembers((Member[])getMembers().clone());
75       return p;
76     } catch (CloneNotSupportedException JavaDoc e) {
77       e.printStackTrace();
78       return null;
79     }
80   }
81 }
82
Popular Tags