KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > table > span > LevelHeaderFactory


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.table.span;
14
15 import com.tonbeller.jpivot.olap.model.Dimension;
16 import com.tonbeller.jpivot.olap.model.EmptyMember;
17 import com.tonbeller.jpivot.olap.model.Hierarchy;
18 import com.tonbeller.jpivot.olap.model.Level;
19 import com.tonbeller.jpivot.olap.model.Member;
20 import com.tonbeller.jpivot.olap.model.Property;
21 import com.tonbeller.jpivot.olap.model.VisitorSupportStrict;
22
23 /**
24  * returns a new span containing the level of the given span.
25  * If the given span contains a hierarchy or dimension (which don't have
26  * a single level) the new span contains the hierarchy or dimension.
27  * @author av
28  */

29 public class LevelHeaderFactory extends VisitorSupportStrict implements SpanVisitor, SpanHeaderFactory {
30   Span header;
31
32   /**
33    * @see com.tonbeller.jpivot.ui.table.span.SpanHeaderFactory#create(Span)
34    */

35   public Span create(Span span) {
36     header = (Span)span.clone();
37     span.getObject().accept(this);
38     // level/hierarchy does not have a position
39
header.setPosition(null);
40     return header;
41   }
42
43
44   public void visitDimension(Dimension v) {
45     header.setObject(v);
46   }
47
48   public void visitHierarchy(Hierarchy v) {
49     header.setObject(v);
50   }
51
52   public void visitLevel(Level v) {
53     header.setObject(v);
54   }
55
56   public void visitMember(Member v) {
57     header.setObject(v.getLevel());
58   }
59
60   public void visitProperty(Property v) {
61     header.setObject(new PropertyHeading(v.getLabel()));
62   }
63
64   public void visitPropertyHeading(PropertyHeading heading) {
65     header.setObject(new PropertyHeading(heading.getLabel()));
66   }
67
68   public void visitEmptyMember(EmptyMember v) {
69     header.setObject(v);
70   }
71
72 }
73
Popular Tags