KickJava   Java API By Example, From Geeks To Geeks.

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


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 hierarchy of the given span.
25  * If the given span contains a dimension (which does not have
26  * a single hierarchy) the new span contains the dimension.
27  * @author av
28  */

29 public class HierarchyHeaderFactory 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     return header;
39   }
40
41
42   public void visitDimension(Dimension v) {
43     header.setObject(v);
44   }
45
46   public void visitHierarchy(Hierarchy v) {
47     header.setObject(v);
48   }
49
50   public void visitLevel(Level v) {
51     header.setObject(v.getHierarchy());
52   }
53
54   public void visitMember(Member v) {
55     header.setObject(v.getLevel().getHierarchy());
56   }
57
58   public void visitProperty(Property v) {
59     header.setObject(new PropertyHeading(v.getLabel()));
60   }
61
62   public void visitPropertyHeading(PropertyHeading heading) {
63     header.setObject(new PropertyHeading(heading.getLabel()));
64   }
65
66   public void visitEmptyMember(EmptyMember v) {
67     header.setObject(v);
68   }
69
70
71 }
72
73
74
Popular Tags