KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > rolap > RolapCalculatedMember


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/rolap/RolapCalculatedMember.java#23 $
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) 2001-2002 Kana Software, Inc.
7 // Copyright (C) 2001-2006 Julian Hyde and others
8 // All Rights Reserved.
9 // You must accept the terms of that agreement to use this software.
10 //
11 // jhyde, 26 August, 2001
12 */

13
14 package mondrian.rolap;
15
16 import mondrian.olap.*;
17
18 /**
19  * A <code>RolapCalculatedMember</code> is a member based upon a
20  * {@link Formula}.
21  *
22  * <p>It is created before the formula has been resolved; the formula is
23  * responsible for setting the "format_string" property.
24  *
25  * @author jhyde
26  * @since 26 August, 2001
27  * @version $Id: //open/mondrian/src/main/mondrian/rolap/RolapCalculatedMember.java#23 $
28  */

29 class RolapCalculatedMember extends RolapMember {
30     private final Formula formula;
31
32     RolapCalculatedMember(
33             RolapMember parentMember, RolapLevel level, String JavaDoc name,
34             Formula formula) {
35         super(parentMember, level, name);
36         this.formula = formula;
37     }
38
39     // override RolapMember
40
public int getSolveOrder() {
41         final Number JavaDoc solveOrder = formula.getSolveOrder();
42         return solveOrder == null ? 0 : solveOrder.intValue();
43     }
44
45     public Object JavaDoc getPropertyValue(String JavaDoc propertyName, boolean matchCase) {
46         if (Util.equal(propertyName, Property.FORMULA.name, matchCase)) {
47             return formula;
48         } else if (Util.equal(propertyName, Property.CHILDREN_CARDINALITY.name, matchCase)) {
49             // Looking up children is unnecessary for calculated member.
50
// If do that, SQLException will be thrown.
51
return 0;
52         } else {
53             return super.getPropertyValue(propertyName, matchCase);
54         }
55     }
56
57     public boolean isCalculated() {
58         return true;
59     }
60
61     public boolean isCalculatedInQuery() {
62         final String JavaDoc memberScope =
63                 (String JavaDoc) getPropertyValue(Property.MEMBER_SCOPE.name);
64         return memberScope == null ||
65                 memberScope.equals("QUERY");
66     }
67
68     public Exp getExpression() {
69         return formula.getExpression();
70     }
71
72     public Formula getFormula() {
73         return formula;
74     }
75 }
76
77
78 // End RolapCalculatedMember.java
79
Popular Tags