KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > olap > type > TupleType


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/olap/type/TupleType.java#5 $
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) 2005-2006 Julian Hyde
7 // All Rights Reserved.
8 // You must accept the terms of that agreement to use this software.
9 */

10 package mondrian.olap.type;
11
12 import mondrian.olap.*;
13
14 /**
15  * Tuple type.
16  *
17  * @author jhyde
18  * @since Feb 17, 2005
19  * @version $Id: //open/mondrian/src/main/mondrian/olap/type/TupleType.java#5 $
20  */

21 public class TupleType implements Type {
22     public final Type[] elementTypes;
23
24     /**
25      * Creates a type representing a tuple whose fields are the given types.
26      */

27     public TupleType(Type[] elementTypes) {
28         assert elementTypes != null;
29         this.elementTypes = elementTypes.clone();
30     }
31
32     public boolean usesDimension(Dimension dimension, boolean maybe) {
33         for (Type elementType : elementTypes) {
34             if (elementType.usesDimension(dimension, maybe)) {
35                 return true;
36             }
37         }
38         return false;
39     }
40
41     public Dimension getDimension() {
42         throw new UnsupportedOperationException JavaDoc();
43     }
44
45     public Hierarchy getHierarchy() {
46         throw new UnsupportedOperationException JavaDoc();
47     }
48
49     public Level getLevel() {
50         throw new UnsupportedOperationException JavaDoc();
51     }
52
53     public Type getValueType() {
54         for (Type elementType : elementTypes) {
55             if (elementType instanceof MemberType) {
56                 MemberType memberType = (MemberType) elementType;
57                 if (memberType.getDimension().isMeasures()) {
58                     return memberType.getValueType();
59                 }
60             }
61         }
62         return new ScalarType();
63     }
64 }
65
66 // End TupleType.java
67
Popular Tags