Class AbstractCalc
- All Implemented Interfaces:
Calc
- Direct Known Subclasses:
AbstractBooleanCalc,AbstractDateTimeCalc,AbstractDimensionCalc,AbstractDoubleCalc,AbstractHierarchyCalc,AbstractIntegerCalc,AbstractIterCalc,AbstractLevelCalc,AbstractListCalc,AbstractMemberCalc,AbstractStringCalc,AbstractTupleCalc,GenericCalc,GenericIterCalc,MemberOrderKeyFunDef.CalcImpl
Calc interface.- Since:
- Sep 27, 2005
- Author:
- jhyde
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractCalc(Exp exp, Calc[] calcs) Creates an AbstractCalc. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(CalcWriter calcWriter) Prints this expression, by accepting a visitingCalcWriter.static booleananyDepends(Calc[] calcs, Hierarchy hierarchy) Returns true if one of the calcs depends on the given dimension.static booleananyDependsButFirst(Calc[] calcs, Hierarchy hierarchy) Returns true if calc[0] depends on dimension, else false if calc[0] returns dimension, else true if any of the other calcs depend on dimension.static booleanbutDepends(Calc[] calcs, Hierarchy hierarchy) Returns true if any of the calcs depend on dimension, else false if any of the calcs return dimension, else true.protected voidcollectArguments(Map<String, Object> arguments) Collects any other arguments to this calc.booleanReturns whether this expression depends upon a given hierarchy.Returns any other arguments to this calc.Calc[]getCalcs()Returns this expression's child expressions.protected StringgetName()Returns the name of this expression type, used when serializing an expression to a string.Returns style in which the result of evaluating this expression is returned.getType()Returns the type of this expression.booleanisWrapperFor(Class<?> iface) Default implementation just does 'instanceof TargetClass'.static EvaluatorsimplifyEvaluator(Calc calc, Evaluator evaluator) Returns a simplified evalator whose context is the same for every dimension which an expression depends on, and the default member for every dimension which it does not depend on.<T> TDefault implementation just casts to TargetClass.
-
Field Details
-
type
-
exp
-
-
Constructor Details
-
AbstractCalc
Creates an AbstractCalc.- Parameters:
exp- Source expressioncalcs- Child compiled expressions
-
-
Method Details
-
getType
Description copied from interface:CalcReturns the type of this expression. -
isWrapperFor
Default implementation just does 'instanceof TargetClass'. Subtypes that are wrappers should override.- Specified by:
isWrapperForin interfaceCalc
-
unwrap
Default implementation just casts to TargetClass. Subtypes that are wrappers should override. -
accept
Description copied from interface:CalcPrints this expression, by accepting a visitingCalcWriter. -
getName
Returns the name of this expression type, used when serializing an expression to a string.The default implementation tries to extract a name from a function call, if any, then prints the last part of the class name.
-
getCalcs
Returns this expression's child expressions. -
dependsOn
Description copied from interface:CalcReturns whether this expression depends upon a given hierarchy.If it does not depend on the hierarchy, then re-evaluating the expression with a different member of this context must produce the same answer.
Some examples:- The expression
depends on all dimensions except[Measures].[Unit Sales][Measures]. - The boolean expression
depends on all hierarchies except [Measures] and [Time].([Measures].[Unit Sales], [Time].[1997]) > 1000 - The list expression
depends upon all hierarchies except [Store] and [Measures]. How so? Normally the scalar expression would depend upon all hierarchies except [Measures], but theFilter([Store].[USA].Children, [Measures].[Unit Sales] < 50)Filterfunction sets the [Store] context before evaluating the scalar expression, so it is not inherited from the surrounding context.
- The expression
-
anyDepends
Returns true if one of the calcs depends on the given dimension. -
anyDependsButFirst
Returns true if calc[0] depends on dimension, else false if calc[0] returns dimension, else true if any of the other calcs depend on dimension.Typical application:
Aggregate({Set}, {Value Expression})depends upon everything {Value Expression} depends upon, except the dimensions of {Set}. -
butDepends
Returns true if any of the calcs depend on dimension, else false if any of the calcs return dimension, else true. -
getArguments
Returns any other arguments to this calc.- Returns:
- Collection of name/value pairs, represented as a map
-
collectArguments
Collects any other arguments to this calc.The default implementation returns name, class, type, resultStyle. A subclass must call super, but may add other arguments.
- Parameters:
arguments- Collection of name/value pairs, represented as a map
-
simplifyEvaluator
Returns a simplified evalator whose context is the same for every dimension which an expression depends on, and the default member for every dimension which it does not depend on.The default member is often the 'all' member, so this evaluator is usually the most efficient context in which to evaluate the expression.
- Parameters:
calc-evaluator-
-
getResultStyle
Description copied from interface:CalcReturns style in which the result of evaluating this expression is returned.One application of this method is for the compiler to figure out whether the compiled expression is returning a mutable list. If a mutable list is required, the compiler can create a mutable copy.
- Specified by:
getResultStylein interfaceCalc- See Also:
-