public class ResultStyleCompiler extends DelegatingExpCompiler
ResultStyleCompiler
can be used to assure that
the use of the container ResultStyle: ITERABLE, LIST and MUTABLE_LIST;
can be requested by any Calc. This ExpCompiler injects into the
Exp hierarchy a special Calc, the MultiCalc, that evaluates
its three child Calc's (one for ITERABLE, LIST and MUTABLE_LIST)
and compares the lists returned to make sure that they are the
same. This comparison can only be done when the Member evaluation
stage of query evaluation is begin done the last time.
[Think about it - how can you tell when the evaluation is happening
for the last time.] Evaluation is called from the RolapResult's
constructor calling the method executeAxis. This happens one or
more times in the while-loop. These evaluations may not be complete;
you can not necessarily compare results. Then, evaluation occurs
just below the while-loop, again calling executeAxis. In this
case the evaluation is complete. The trick is to llok a the
stack and when one changes the line number from which one is
being called, then one knows one is being called by the second
executeAxis call in the RolapResult constructor.Modifier and Type | Class and Description |
---|---|
(package private) static class |
ResultStyleCompiler.MultiCalc
Calc with three child Calcs, one for ITERABLE, LIST and MUTABLE_LIST,
which are evaluated during the normal evaluation process.
|
ExpCompiler.Factory
Constructor and Description |
---|
ResultStyleCompiler(Evaluator evaluator,
Validator validator,
List<ResultStyle> resultStyles)
Constructor which uses the ExpCompiler.Factory to get the
default ExpCompiler as an instance variable - ResultStyleCompiler
is a wrapper.
|
Modifier and Type | Method and Description |
---|---|
Calc |
compile(Exp exp)
Compiles an expression.
|
Calc |
compileAs(Exp exp,
Type resultType,
List<ResultStyle> resultStyles)
Compiles an expression to a given result type.
|
afterCompile, compileBoolean, compileDateTime, compileDimension, compileDouble, compileHierarchy, compileInteger, compileIter, compileLevel, compileList, compileList, compileMember, compileScalar, compileString, compileTuple, getAcceptableResultStyles, getEvaluator, getValidator, registerParameter
public ResultStyleCompiler(Evaluator evaluator, Validator validator, List<ResultStyle> resultStyles)
public Calc compile(Exp exp)
ExpCompiler
compile
in interface ExpCompiler
compile
in class DelegatingExpCompiler
exp
- Expressionpublic Calc compileAs(Exp exp, Type resultType, List<ResultStyle> resultStyles)
ExpCompiler
If resultType
is not null, casts the expression to that
type. Throws an exception if that conversion is not allowed by the
type system.
The preferredResultStyles
parameter specifies a list
of desired result styles. It must not be null, but may be empty.
compileAs
in interface ExpCompiler
compileAs
in class DelegatingExpCompiler
exp
- ExpressionresultType
- Desired result type, or null to use expression's
current typeresultStyles
- List of result types, in descending order
of preference. Never null.