1 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 23 public class TestPosition extends PositionImpl { 24 TestAxis axis; 25 public TestPosition(TestAxis axis) { 26 this.axis = axis; 27 } 28 32 public TestAxis getAxis() { 33 return axis; 34 } 35 36 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 clone() { 72 try { 73 TestPosition p = (TestPosition)super.clone(); 74 p.setMembers((Member[])getMembers().clone()); 75 return p; 76 } catch (CloneNotSupportedException e) { 77 e.printStackTrace(); 78 return null; 79 } 80 } 81 } 82 | Popular Tags |