/
HierarchyExpr.java
73 lines (62 loc) · 1.67 KB
/
HierarchyExpr.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
// $Id$
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// (C) Copyright 2006-2006 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.mdx;
import mondrian.olap.*;
import mondrian.olap.type.HierarchyType;
import mondrian.olap.type.Type;
import mondrian.calc.*;
import mondrian.calc.impl.ConstantCalc;
/**
* Usage of a {@link mondrian.olap.Hierarchy} as an MDX expression.
*
* @author jhyde
* @version $Id$
* @since Sep 26, 2005
*/
public class HierarchyExpr extends ExpBase implements Exp {
private final Hierarchy hierarchy;
/**
* Creates a hierarchy expression.
*
* @param hierarchy Hierarchy
* @pre hierarchy != null
*/
public HierarchyExpr(Hierarchy hierarchy) {
Util.assertPrecondition(hierarchy != null, "hierarchy != null");
this.hierarchy = hierarchy;
}
/**
* Returns the hierarchy.
*
* @post return != null
*/
public Hierarchy getHierarchy() {
return hierarchy;
}
public String toString() {
return hierarchy.getUniqueName();
}
public Type getType() {
return HierarchyType.forHierarchy(hierarchy);
}
public Object clone() {
return new HierarchyExpr(hierarchy);
}
public int getCategory() {
return Category.Hierarchy;
}
public Exp accept(Validator validator) {
return this;
}
public Calc accept(ExpCompiler compiler) {
return ConstantCalc.constantHierarchy(hierarchy);
}
}
// End HierarchyExpr.java