Package mondrian.calc.impl
Class AbstractExpCompiler
java.lang.Object
mondrian.calc.impl.AbstractExpCompiler
- All Implemented Interfaces:
ExpCompiler
- Direct Known Subclasses:
BetterExpCompiler
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
ConstructorDescriptionAbstractExpCompiler
(Evaluator evaluator, Validator validator) Creates an AbstractExpCompilerAbstractExpCompiler
(Evaluator evaluator, Validator validator, List<ResultStyle> resultStyles) Creates an AbstractExpCompiler which is constrained to produce one of a set of result styles. -
Method Summary
Modifier and TypeMethodDescriptionCompiles an expression.compileAs
(Exp exp, Type resultType, List<ResultStyle> preferredResultTypes) Compiles an expression to a given result type.compileBoolean
(Exp exp) Compiles an expression which yields aboolean
result.compileDateTime
(Exp exp) Compiles an expression which yields aDate
result.compileDimension
(Exp exp) Compiles an expression which yields aDimension
result.compileDouble
(Exp exp) Compiles an expression which yields adouble
result.compileHierarchy
(Exp exp) Compiles an expression which yields aHierarchy
result.compileInteger
(Exp exp) Compiles an expression which yields anint
result.compileIter
(Exp exp) Compiles an expression which yields an immutableIterable
result.compileLevel
(Exp exp) Compiles an expression which yields aLevel
result.compileList
(Exp exp) Compiles an expression which yields an immutableTupleList
result.compileList
(Exp exp, boolean mutable) Compiles an expression which yieldsTupleList
result.compileMember
(Exp exp) Compiles an expression which yields aMember
result.compileScalar
(Exp exp, boolean specific) Compiles an expression to yield a scalar result.compileString
(Exp exp) Compiles an expression which yields aString
result.compileTuple
(Exp exp) Compiles an expression which yields a tuple result.Returns a list of theResultStyle
s acceptable to the caller.Returns the evaluator to be used for evaluating expressions during the compilation process.Returns the validator which was used to validate this expression.registerParameter
(Parameter parameter) Implements a parameter, returning a unique slot which will hold the parameter's value.Converts an iterable over tuples to a list of tuples.
-
Constructor Details
-
AbstractExpCompiler
Creates an AbstractExpCompiler- Parameters:
evaluator
- Evaluatorvalidator
- 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
- Evaluatorvalidator
- ValidatorresultStyles
- List of result styles, preferred first, must not be
-
-
Method Details
-
getEvaluator
Description copied from interface:ExpCompiler
Returns the evaluator to be used for evaluating expressions during the compilation process.- Specified by:
getEvaluator
in interfaceExpCompiler
-
getValidator
Description copied from interface:ExpCompiler
Returns the validator which was used to validate this expression.- Specified by:
getValidator
in interfaceExpCompiler
- Returns:
- validator
-
compile
Compiles an expression. Uses the current ResultStyle to compile the expression.- Specified by:
compile
in interfaceExpCompiler
- Parameters:
exp
- Expression- Returns:
- Compiled expression
-
compileAs
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 interfaceExpCompiler
- Parameters:
exp
- ExpressionresultType
- Desired result type, or null to use expression's current typepreferredResultTypes
- List of result types, in descending order of preference. Never null.- Returns:
- Compiled expression, or null if none can satisfy
-
compileMember
Description copied from interface:ExpCompiler
Compiles an expression which yields aMember
result.- Specified by:
compileMember
in interfaceExpCompiler
-
compileLevel
Description copied from interface:ExpCompiler
Compiles an expression which yields aLevel
result.- Specified by:
compileLevel
in interfaceExpCompiler
-
compileDimension
Description copied from interface:ExpCompiler
Compiles an expression which yields aDimension
result.- Specified by:
compileDimension
in interfaceExpCompiler
-
compileHierarchy
Description copied from interface:ExpCompiler
Compiles an expression which yields aHierarchy
result.- Specified by:
compileHierarchy
in interfaceExpCompiler
-
compileInteger
Description copied from interface:ExpCompiler
Compiles an expression which yields anint
result. The expression is implicitly converted into a scalar.- Specified by:
compileInteger
in interfaceExpCompiler
-
compileString
Description copied from interface:ExpCompiler
Compiles an expression which yields aString
result. The expression is implicitly converted into a scalar.- Specified by:
compileString
in interfaceExpCompiler
-
compileDateTime
Description copied from interface:ExpCompiler
Compiles an expression which yields aDate
result. The expression is implicitly converted into a scalar.- Specified by:
compileDateTime
in interfaceExpCompiler
-
compileList
Description copied from interface:ExpCompiler
Compiles an expression which yields an immutableTupleList
result.Always equivalent to
.ExpCompiler.compileList(mondrian.olap.Exp)
(exp, false)- Specified by:
compileList
in interfaceExpCompiler
-
compileList
Description copied from interface:ExpCompiler
Compiles an expression which yieldsTupleList
result.Such an expression is generally a list of
Member
objects or a list of tuples (each represented by aMember
array).- Specified by:
compileList
in interfaceExpCompiler
- Parameters:
exp
- Expressionmutable
- Whether resulting list is mutable
-
toList
Converts an iterable over tuples to a list of tuples.- Parameters:
calc
- Calc- Returns:
- List calculation.
-
compileIter
Description copied from interface:ExpCompiler
Compiles an expression which yields an immutableIterable
result.- Specified by:
compileIter
in interfaceExpCompiler
- Parameters:
exp
- Expression- Returns:
- Calculator which yields an Iterable
-
compileBoolean
Description copied from interface:ExpCompiler
Compiles an expression which yields aboolean
result.- Specified by:
compileBoolean
in interfaceExpCompiler
- Parameters:
exp
- Expression- Returns:
- Calculator which yields a boolean
-
compileDouble
Description copied from interface:ExpCompiler
Compiles an expression which yields adouble
result.- Specified by:
compileDouble
in interfaceExpCompiler
- Parameters:
exp
- Expression- Returns:
- Calculator which yields a double
-
compileTuple
Description copied from interface:ExpCompiler
Compiles an expression which yields a tuple result.- Specified by:
compileTuple
in interfaceExpCompiler
- Parameters:
exp
- Expression- Returns:
- Calculator which yields a tuple
-
compileScalar
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 interfaceExpCompiler
- Parameters:
exp
- Expressionspecific
- Whether to try to use the specific compile method for scalar types. For example, ifspecific
is true andexp
is a string expression, callsExpCompiler.compileString(mondrian.olap.Exp)
- Returns:
- Calculation which returns the scalar value of the expression
-
registerParameter
Description copied from interface:ExpCompiler
Implements a parameter, returning a unique slot which will hold the parameter's value.- Specified by:
registerParameter
in interfaceExpCompiler
- Parameters:
parameter
- Parameter- Returns:
- Slot
-
getAcceptableResultStyles
Description copied from interface:ExpCompiler
Returns a list of theResultStyle
s acceptable to the caller.- Specified by:
getAcceptableResultStyles
in interfaceExpCompiler
-