mondrian.calc.impl
Class AbstractListCalc

java.lang.Object
  extended by mondrian.calc.impl.AbstractCalc
      extended by mondrian.calc.impl.AbstractListCalc
All Implemented Interfaces:
Calc, ListCalc, MemberListCalc, TupleListCalc
Direct Known Subclasses:
CrossJoinFunDef.BaseListCalc, DistinctFunDef.CalcImpl

public abstract class AbstractListCalc
extends AbstractCalc
implements ListCalc, MemberListCalc, TupleListCalc

Abstract implementation of the ListCalc interface.

The derived class must implement the ListCalc.evaluateList(mondrian.olap.Evaluator) method, and the evaluate(mondrian.olap.Evaluator) method will call it.

Since:
Sep 27, 2005
Version:
$Id: //open/mondrian/src/main/mondrian/calc/impl/AbstractListCalc.java#11 $
Author:
jhyde

Field Summary
protected  boolean tuple
           
 
Fields inherited from class mondrian.calc.impl.AbstractCalc
exp, type
 
Constructor Summary
protected AbstractListCalc(Exp exp, Calc[] calcs)
          Creates an abstract implementation of a compiled expression which returns a mutable list.
protected AbstractListCalc(Exp exp, Calc[] calcs, boolean mutable)
          Creates an abstract implementation of a compiled expression which returns a list.
 
Method Summary
 java.lang.Object evaluate(Evaluator evaluator)
          Evaluates this expression.
protected  java.util.List evaluateEitherList(Evaluator evaluator)
          Helper method with which to implement ListCalc.evaluateList(mondrian.olap.Evaluator) if you have implemented evaluateMemberList(mondrian.olap.Evaluator) and evaluateTupleList(mondrian.olap.Evaluator).
 java.util.List<Member> evaluateMemberList(Evaluator evaluator)
          Evaluates an expression to yield a list of members.
 java.util.List<Member[]> evaluateTupleList(Evaluator evaluator)
          Evaluates an expression to yield a list of tuples.
 ResultStyle getResultStyle()
          Returns style in which the result of evaluating this expression is returned.
 SetType getType()
          Returns the type of this expression.
 
Methods inherited from class mondrian.calc.impl.AbstractCalc
accept, anyDepends, anyDependsButFirst, butDepends, dependsOn, getArguments, getCalcs, getName, simplifyEvaluator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface mondrian.calc.ListCalc
evaluateList
 
Methods inherited from interface mondrian.calc.Calc
accept, dependsOn
 

Field Detail

tuple

protected final boolean tuple
Constructor Detail

AbstractListCalc

protected AbstractListCalc(Exp exp,
                           Calc[] calcs)
Creates an abstract implementation of a compiled expression which returns a mutable list.

Parameters:
exp - Expression which was compiled
calcs - List of child compiled expressions (for dependency analysis)

AbstractListCalc

protected AbstractListCalc(Exp exp,
                           Calc[] calcs,
                           boolean mutable)
Creates an abstract implementation of a compiled expression which returns a list.

Parameters:
exp - Expression which was compiled
calcs - List of child compiled expressions (for dependency analysis)
mutable - Whether the list is mutable
Method Detail

getType

public SetType getType()
Description copied from interface: Calc
Returns the type of this expression.

Specified by:
getType in interface Calc
Overrides:
getType in class AbstractCalc

evaluate

public java.lang.Object evaluate(Evaluator evaluator)
Description copied from interface: Calc
Evaluates this expression.

Specified by:
evaluate in interface Calc
Parameters:
evaluator - Provides dimensional context in which to evaluate this expression
Returns:
Result of expression evaluation

getResultStyle

public ResultStyle getResultStyle()
Description copied from interface: Calc
Returns 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:
getResultStyle in interface Calc
Overrides:
getResultStyle in class AbstractCalc
See Also:
ExpCompiler.compileList(mondrian.olap.Exp, boolean)

evaluateMemberList

public java.util.List<Member> evaluateMemberList(Evaluator evaluator)
Description copied from interface: MemberListCalc
Evaluates an expression to yield a list of members.

The list is immutable if Calc.getResultStyle() yields ResultStyle.MUTABLE_LIST. Otherwise, the caller must not modify the list.

Specified by:
evaluateMemberList in interface MemberListCalc
Parameters:
evaluator - Evaluation context
Returns:
A list of members, never null.

evaluateTupleList

public java.util.List<Member[]> evaluateTupleList(Evaluator evaluator)
Description copied from interface: TupleListCalc
Evaluates an expression to yield a list of tuples.

Each tuple is represented by an array of members.

The list is immutable if Calc.getResultStyle() yields ResultStyle.MUTABLE_LIST. Otherwise, the caller must not modify the list.

Specified by:
evaluateTupleList in interface TupleListCalc
Parameters:
evaluator - Evaluation context
Returns:
A list of tuples, never null.

evaluateEitherList

protected java.util.List evaluateEitherList(Evaluator evaluator)
Helper method with which to implement ListCalc.evaluateList(mondrian.olap.Evaluator) if you have implemented evaluateMemberList(mondrian.olap.Evaluator) and evaluateTupleList(mondrian.olap.Evaluator).

Parameters:
evaluator - Evaluator
Returns:
List

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