mondrian.calc.impl
Class AbstractExpCompiler

java.lang.Object
  extended by mondrian.calc.impl.AbstractExpCompiler
All Implemented Interfaces:
ExpCompiler
Direct Known Subclasses:
BetterExpCompiler

public class AbstractExpCompiler
extends Object
implements ExpCompiler

Abstract implementation of the ExpCompiler interface.

Since:
Sep 29, 2005
Author:
jhyde
 

Nested Class Summary
 
Nested classes/interfaces inherited from interface mondrian.calc.ExpCompiler
ExpCompiler.Factory
 
Constructor Summary
AbstractExpCompiler(Evaluator evaluator, Validator validator)
          Creates an AbstractExpCompiler
AbstractExpCompiler(Evaluator evaluator, Validator validator, List<ResultStyle> resultStyles)
          Creates an AbstractExpCompiler which is constrained to produce one of a set of result styles.
 
Method Summary
 Calc compile(Exp exp)
          Compiles an expression.
 Calc compileAs(Exp exp, Type resultType, List<ResultStyle> preferredResultTypes)
          Compiles an expression to a given result type.
 BooleanCalc compileBoolean(Exp exp)
          Compiles an expression which yields a boolean result.
 DateTimeCalc compileDateTime(Exp exp)
          Compiles an expression which yields a Date result.
 DimensionCalc compileDimension(Exp exp)
          Compiles an expression which yields a Dimension result.
 DoubleCalc compileDouble(Exp exp)
          Compiles an expression which yields a double result.
 HierarchyCalc compileHierarchy(Exp exp)
          Compiles an expression which yields a Hierarchy result.
 IntegerCalc compileInteger(Exp exp)
          Compiles an expression which yields an int result.
 IterCalc compileIter(Exp exp)
          Compiles an expression which yields an immutable Iterable result.
 LevelCalc compileLevel(Exp exp)
          Compiles an expression which yields a Level result.
 ListCalc compileList(Exp exp)
          Compiles an expression which yields an immutable List result.
 ListCalc compileList(Exp exp, boolean mutable)
          Compiles an expression which yields List result.
 MemberCalc compileMember(Exp exp)
          Compiles an expression which yields a Member result.
 Calc compileScalar(Exp exp, boolean specific)
          Compiles an expression to yield a scalar result.
 StringCalc compileString(Exp exp)
          Compiles an expression which yields a String result.
 TupleCalc compileTuple(Exp exp)
          Compiles an expression which yields a tuple result.
 List<ResultStyle> getAcceptableResultStyles()
          Returns a list of the ResultStyles acceptable to the caller.
 Evaluator getEvaluator()
          Returns the evaluator to be used for evaluating expressions during the compilation process.
 Validator getValidator()
          Returns the validator which was used to validate this expression.
 ParameterSlot registerParameter(Parameter parameter)
          Implements a parameter, returning a unique slot which will hold the parameter's value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractExpCompiler

public AbstractExpCompiler(Evaluator evaluator,
                           Validator validator)
Creates an AbstractExpCompiler

Parameters:
evaluator - Evaluator
validator - Validator

AbstractExpCompiler

public AbstractExpCompiler(Evaluator evaluator,
                           Validator validator,
                           List<ResultStyle> resultStyles)
Creates an AbstractExpCompiler which is constrained to produce one of a set of result styles.

Parameters:
evaluator - Evaluator
validator - Validator
resultStyles - List of result styles, preferred first, must not be
Method Detail

getEvaluator

public Evaluator getEvaluator()
Description copied from interface: ExpCompiler
Returns the evaluator to be used for evaluating expressions during the compilation process.

Specified by:
getEvaluator in interface ExpCompiler

getValidator

public Validator getValidator()
Description copied from interface: ExpCompiler
Returns the validator which was used to validate this expression.

Specified by:
getValidator in interface ExpCompiler
Returns:
validator

compile

public Calc compile(Exp exp)
Compiles an expression. Uses the current ResultStyle to compile the expression.

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

compileAs

public Calc compileAs(Exp exp,
                      Type resultType,
                      List<ResultStyle> preferredResultTypes)
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. Uses a new ResultStyle to compile the expression.

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

compileMember

public MemberCalc compileMember(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression which yields a Member result.

Specified by:
compileMember in interface ExpCompiler

compileLevel

public LevelCalc compileLevel(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression which yields a Level result.

Specified by:
compileLevel in interface ExpCompiler

compileDimension

public DimensionCalc compileDimension(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression which yields a Dimension result.

Specified by:
compileDimension in interface ExpCompiler

compileHierarchy

public HierarchyCalc compileHierarchy(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression which yields a Hierarchy result.

Specified by:
compileHierarchy in interface ExpCompiler

compileInteger

public IntegerCalc compileInteger(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression which yields an int result. The expression is implicitly converted into a scalar.

Specified by:
compileInteger in interface ExpCompiler

compileString

public StringCalc compileString(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression which yields a String result. The expression is implicitly converted into a scalar.

Specified by:
compileString in interface ExpCompiler

compileDateTime

public DateTimeCalc compileDateTime(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression which yields a Date result. The expression is implicitly converted into a scalar.

Specified by:
compileDateTime in interface ExpCompiler

compileList

public ListCalc compileList(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression which yields an immutable List result.

Always equivalent to ExpCompiler.compileList(mondrian.olap.Exp)(exp, false).

Specified by:
compileList in interface ExpCompiler

compileList

public ListCalc compileList(Exp exp,
                            boolean mutable)
Description copied from interface: ExpCompiler
Compiles an expression which yields List result.

Such an expression is generally a list of Member objects or a list of tuples (each represented by a Member array).

See ExpCompiler.compileList(mondrian.olap.Exp).

Specified by:
compileList in interface ExpCompiler
Parameters:
exp - Expression
mutable - Whether resulting list is mutable

compileIter

public IterCalc compileIter(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression which yields an immutable Iterable result.

Specified by:
compileIter in interface ExpCompiler
Parameters:
exp - Expression
Returns:
Calculator which yields an Iterable

compileBoolean

public BooleanCalc compileBoolean(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression which yields a boolean result.

Specified by:
compileBoolean in interface ExpCompiler
Parameters:
exp - Expression
Returns:
Calculator which yields a boolean

compileDouble

public DoubleCalc compileDouble(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression which yields a double result.

Specified by:
compileDouble in interface ExpCompiler
Parameters:
exp - Expression
Returns:
Calculator which yields a double

compileTuple

public TupleCalc compileTuple(Exp exp)
Description copied from interface: ExpCompiler
Compiles an expression which yields a tuple result.

Specified by:
compileTuple in interface ExpCompiler
Parameters:
exp - Expression
Returns:
Calculator which yields a tuple

compileScalar

public Calc compileScalar(Exp exp,
                          boolean specific)
Description copied from interface: ExpCompiler
Compiles an expression to yield a scalar result.

If the expression yields a member or tuple, the calculator will automatically apply that member or tuple to the current dimensional context and return the value of the current measure.

Specified by:
compileScalar in interface ExpCompiler
Parameters:
exp - Expression
specific - Whether to try to use the specific compile method for scalar types. For example, if specific is true and exp is a string expression, calls ExpCompiler.compileString(mondrian.olap.Exp)
Returns:
Calculation which returns the scalar value of the expression

registerParameter

public ParameterSlot registerParameter(Parameter parameter)
Description copied from interface: ExpCompiler
Implements a parameter, returning a unique slot which will hold the parameter's value.

Specified by:
registerParameter in interface ExpCompiler
Parameters:
parameter - Parameter
Returns:
Slot

getAcceptableResultStyles

public List<ResultStyle> getAcceptableResultStyles()
Description copied from interface: ExpCompiler
Returns a list of the ResultStyles acceptable to the caller.

Specified by:
getAcceptableResultStyles in interface ExpCompiler

SourceForge.net_Logo