KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > olap > Evaluator


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/olap/Evaluator.java#24 $
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-2007 Julian Hyde and others
8 // All Rights Reserved.
9 // You must accept the terms of that agreement to use this software.
10 //
11 // jhyde, 27 July, 2001
12 */

13
14 package mondrian.olap;
15
16 import mondrian.calc.ParameterSlot;
17 import java.util.List JavaDoc;
18 import java.util.Locale JavaDoc;
19
20 /**
21  * An <code>Evaluator</code> holds the context necessary to evaluate an
22  * expression.
23  *
24  * @author jhyde
25  * @since 27 July, 2001
26  * @version $Id: //open/mondrian/src/main/mondrian/olap/Evaluator.java#24 $
27  */

28 public interface Evaluator {
29
30     /**
31      * Returns the current cube.
32      */

33     Cube getCube();
34
35     /**
36      * Returns the current query.
37      */

38     Query getQuery();
39
40     /**
41      * Creates a new evaluator with each given member overriding the state of
42      * the current validator for its dimension. Other dimensions retain the
43      * same state as this validator.
44      */

45     Evaluator push(Member[] members);
46
47     /**
48      * Creates a new evaluator with the same state.
49      * Equivalent to {@link #push(Member[]) push(new Member[0])}.
50      */

51     Evaluator push();
52
53     /**
54      * Creates a new evaluator with the same state except for one member.
55      * Equivalent to
56      * {@link #push(Member[]) push(new Member[] &#124;member&#125;)}.
57      */

58     Evaluator push(Member member);
59
60     /**
61      * Restores previous evaluator.
62      */

63     Evaluator pop();
64
65     /**
66      * Makes <code>member</code> the current member of its dimension. Returns
67      * the previous context.
68      *
69      * @pre member != null
70      * @post return != null
71      */

72     Member setContext(Member member);
73
74     void setContext(List JavaDoc<Member> memberList);
75
76     void setContext(Member[] members);
77
78     Member getContext(Dimension dimension);
79
80     /**
81      * Calculates and returns the value of the cell at the current context.
82      */

83     Object JavaDoc evaluateCurrent();
84
85     /**
86      * Returns the format string for this cell. This is computed by evaluating
87      * the format expression in the current context, and therefore different
88      * cells may have different format strings.
89      */

90     public String JavaDoc getFormatString();
91
92     /**
93      * Formats a value as a string according to the current context's
94      * format.
95      */

96     String JavaDoc format(Object JavaDoc o);
97
98     /**
99      * Formats a value as a string according to the current context's
100      * format, using a given format string.
101      */

102     String JavaDoc format(Object JavaDoc o, String JavaDoc formatString);
103
104     /**
105      * Returns number of ancestor evaluators. Used to check for infinite
106      * loops.
107      *
108      * @post return getParent() == null ? 0 : getParent().getDepth() + 1
109      */

110     int getDepth();
111
112     /**
113      * Returns parent evaluator.
114      */

115     Evaluator getParent();
116
117     /**
118      * Returns the connection's locale.
119      */

120     Locale JavaDoc getConnectionLocale();
121
122     /**
123      * Retrieves the value of property <code>name</code>. If more than one
124      * member in the current context defines that property, the one with the
125      * highest solve order has precedence.
126      *
127      * <p>If the property is not defined, default value is returned.
128      */

129     Object JavaDoc getProperty(String JavaDoc name, Object JavaDoc defaultValue);
130
131     /**
132      * Returns a {@link SchemaReader} appropriate for the current
133      * access-control context.
134      */

135     SchemaReader getSchemaReader();
136
137     /**
138      * Simple caching of the result of an <code>Exp</code>. The
139      * key for the cache consists of all members of the current
140      * context that <code>exp</code> depends on. Members of
141      * independent dimensions are not part of the key.
142      *
143      * @see mondrian.calc.Calc#dependsOn
144      */

145     Object JavaDoc getCachedResult(ExpCacheDescriptor key);
146
147     /**
148      * Returns true for an axis that is NON EMPTY.
149      *
150      * <p>May be used by expression
151      * evaluators to optimize their result. For example, a top-level crossjoin
152      * may be optimized by removing all non-empty set elements before
153      * performing the crossjoin. This is possible because of the identity
154      *
155      * <blockquote><code>nonempty(crossjoin(a, b)) ==
156      * nonempty(crossjoin(nonempty(a), nonempty(b));</code></blockquote>
157      */

158     boolean isNonEmpty();
159
160     /**
161      * Sets whether an expression evaluation should filter out empty cells.
162      * Allows expressions to modify non empty flag to evaluate their children.
163      */

164     void setNonEmpty(boolean nonEmpty);
165
166     /**
167      * Creates an exception which indicates that an error has occurred during
168      * the runtime evaluation of a function. The caller should then throw that
169      * exception.
170      */

171     RuntimeException JavaDoc newEvalException(Object JavaDoc context, String JavaDoc s);
172
173     /**
174      * Evaluates a named set.
175      */

176     Object JavaDoc evaluateNamedSet(String JavaDoc name, Exp exp);
177
178     /**
179      * Returns an array of the members which make up the current context.
180      */

181     Member[] getMembers();
182
183     /**
184      * Returns the number of times that this evaluator has told a lie when
185      * retrieving cell values.
186      */

187     int getMissCount();
188
189     /**
190      * Returns the value of a parameter, evaluating its default value if it is
191      * not set.
192      */

193     Object JavaDoc getParameterValue(ParameterSlot slot);
194
195     /**
196      * @return the iteration length of the current context
197      */

198     int getIterationLength();
199
200     /**
201      * Sets the iteration length for the current evaluator context
202      *
203      * @param length length to be set
204      */

205     void setIterationLength(int length);
206
207     /**
208      * @return true if evaluating axes
209      */

210     boolean isEvalAxes();
211
212     /**
213      * Indicate whether the evaluator is evaluating the axes
214      *
215      * @param evalAxes true if evaluating axes
216      */

217     void setEvalAxes(boolean evalAxes);
218 }
219
220 // End Evaluator.java
221
Popular Tags