KickJava   Java API By Example, From Geeks To Geeks.

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


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.ArrayList JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.List JavaDoc;
18
19 import com.tonbeller.jpivot.olap.model.Member;
20 import com.tonbeller.jpivot.olap.model.Position;
21 import com.tonbeller.jpivot.olap.navi.ChangeSlicer;
22
23 /**
24  * Created on 09.12.2002
25  *
26  * @author av
27  */

28 public class TestChangeSlicer extends TestExtensionSupport implements ChangeSlicer {
29
30   /**
31    * @see com.tonbeller.jpivot.olap.navi.ChangeSlicer#getSlicer()
32    */

33   public Member[] getSlicer() {
34     List JavaDoc list = new ArrayList JavaDoc();
35     TestAxis axis = model().getSlicer();
36     for (Iterator JavaDoc it = axis.getPositions().iterator(); it.hasNext(); ) {
37       Position p = (Position)it.next();
38       if (p.getMembers().length != 1)
39         throw new IllegalArgumentException JavaDoc("slicer position must have exactly one member");
40       list.add(p.getMembers()[0]);
41     }
42     return (Member[])list.toArray(new Member[list.size()]);
43   }
44
45   /**
46    * @see com.tonbeller.jpivot.olap.navi.ChangeSlicer#setSlicer(Member[])
47    */

48   public void setSlicer(Member[] members) {
49     TestAxis axis = TestOlapModelUtils.createAxis(members);
50     model().setSlicer(axis);
51     fireModelChanged();
52   }
53
54 }
55
Popular Tags