mondrian.olap.fun
Class ResultStyleCompiler

java.lang.Object
  extended by mondrian.calc.impl.DelegatingExpCompiler
      extended by mondrian.olap.fun.ResultStyleCompiler
All Implemented Interfaces:
ExpCompiler

public class ResultStyleCompiler
extends DelegatingExpCompiler

The 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.

Since:
Feb 10 2007
Author:
Richard M. Emberson

Nested Class Summary
(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.
 
Nested classes/interfaces inherited from interface mondrian.calc.ExpCompiler
ExpCompiler.Factory
 
Constructor Summary
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.
 
Method Summary
 Calc compile(Exp exp)
          Compiles an expression.
 Calc compileAs(Exp exp, Type resultType, List<ResultStyle> resultStyles)
          Compiles an expression to a given result type.
 
Methods inherited from class mondrian.calc.impl.DelegatingExpCompiler
afterCompile, compileBoolean, compileDateTime, compileDimension, compileDouble, compileHierarchy, compileInteger, compileIter, compileLevel, compileList, compileList, compileMember, compileScalar, compileString, compileTuple, getAcceptableResultStyles, getEvaluator, getValidator, registerParameter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultStyleCompiler

public 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.

Method Detail

compile

public Calc compile(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression.

Specified by:
compile in interface ExpCompiler
Overrides:
compile in class DelegatingExpCompiler
Parameters:
exp - Expression
Returns:
Compiled expression

compileAs

public Calc compileAs(Exp exp,
                      Type resultType,
                      List<ResultStyle> resultStyles)
Description copied from interface: ExpCompiler
Compiles an expression to a given result type.

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.

Specified by:
compileAs in interface ExpCompiler
Overrides:
compileAs in class DelegatingExpCompiler
Parameters:
exp - Expression
resultType - Desired result type, or null to use expression's current type
resultStyles - List of result types, in descending order of preference. Never null.
Returns:
Compiled expression, or null if none can satisfy

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads