Class FunDefBase

java.lang.Object
org.eigenbase.xom.XMLUtil
org.eigenbase.xom.XOMUtil
mondrian.olap.Util
mondrian.olap.fun.FunUtil
mondrian.olap.fun.FunDefBase
All Implemented Interfaces:
FunDef
Direct Known Subclasses:
AbstractAggregateFunDef, CachedExistsFunDef, CacheFunDef, CalculatedChildFunDef, CastFunDef, CoalesceEmptyFunDef, CrossJoinFunDef, ExistingFunDef, HierarchyCurrentMemberFunDef, HierarchyDimensionFunDef, IifFunDef, JavaFunDef, LevelHierarchyFunDef, LevelMembersFunDef, LinReg, MemberHierarchyFunDef, MemberLevelFunDef, MemberOrderKeyFunDef, NamedSetCurrentFunDef, NamedSetCurrentOrdinalFunDef, NativizeSetFunDef, ParameterFunDef, ParenthesesFunDef, RankFunDef, SetFunDef, TupleFunDef, ValidMeasureFunDef, VisualTotalsFunDef

public abstract class FunDefBase extends FunUtil implements FunDef
FunDefBase is the default implementation of FunDef.

Signatures

A function is defined by the following:

ParameterMeaningExample
nameName of the function"Members"
signature Signature of the function "<Dimension>.Members"
description Description of the function "Returns the set of all members in a dimension."
flags Encoding of the syntactic type, return type, and parameter types of this operator. The encoding is described below. "pxd"
The flags field is an string which encodes the syntactic type, return type, and parameter types of this operator.

For example, "pxd" means "an operator with property syntax (p) which returns a set (x) and takes a dimension (d) as its argument".

The arguments are always read from left to right, regardless of the syntactic type of the operator. For example, the "<Set>.Item(<Index>)" operator (signature "mmxn") has the syntax of a method-call, and takes two parameters: a set (x) and a numeric (n).

Since:
26 February, 2002
Author:
jhyde
  • Field Details

    • flags

      protected final int flags
    • returnCategory

      protected final int returnCategory
    • parameterCategories

      protected final int[] parameterCategories
  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Description copied from interface: FunDef
      Returns the name of this function.
      Specified by:
      getName in interface FunDef
    • getDescription

      public String getDescription()
      Description copied from interface: FunDef
      Returns the description of this function.
      Specified by:
      getDescription in interface FunDef
    • getSyntax

      public Syntax getSyntax()
      Description copied from interface: FunDef
      Returns the syntactic type of the function.
      Specified by:
      getSyntax in interface FunDef
    • getReturnCategory

      public int getReturnCategory()
      Description copied from interface: FunDef
      Returns the Category code of the value returned by this function.
      Specified by:
      getReturnCategory in interface FunDef
    • getParameterCategories

      public int[] getParameterCategories()
      Description copied from interface: FunDef
      Returns the types of the arguments of this function. Values are the same as those returned by Exp.getCategory(). The 0th argument of methods and properties are the object they are applied to. Infix operators have two arguments, and prefix operators have one argument.
      Specified by:
      getParameterCategories in interface FunDef
    • createCall

      public Exp createCall(Validator validator, Exp[] args)
      Description copied from interface: FunDef
      Creates an expression which represents a call to this function with a given set of arguments. The result is usually a ResolvedFunCall but not always.
      Specified by:
      createCall in interface FunDef
    • validateArg

      protected Exp validateArg(Validator validator, Exp[] args, int i, int category)
      Validates an argument to a call to this function.

      The default implementation of this method adds an implicit conversion to the correct type. Derived classes may override.

      Parameters:
      validator - Validator
      args - Arguments to this function
      i - Ordinal of argument
      category - Expected category of argument
      Returns:
      Validated argument
    • getResultType

      public Type getResultType(Validator validator, Exp[] args)
      Returns the type of a call to this function with a given set of arguments.

      The default implementation makes the coarse assumption that the return type is in some way related to the type of the first argument. Operators whose arguments don't follow the requirements of this implementation should override this method.

      If the function definition says it returns a literal type (numeric, string, symbol) then it's a fair guess that the function call returns the same kind of value.

      If the function definition says it returns an object type (cube, dimension, hierarchy, level, member) then we check the first argument of the function. Suppose that the function definition says that it returns a hierarchy, and the first argument of the function happens to be a member. Then it's reasonable to assume that this function returns a member.

      Parameters:
      validator - Validator
      args - Arguments to the call to this operator
      Returns:
      result type of a call this function
    • compileCall

      public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler)
      Description copied from interface: FunDef
      Converts a call to this function into executable objects.

      The result must implement the appropriate interface for the result type. For example, a function which returns an integer must return an object which implements IntegerCalc.

      Specified by:
      compileCall in interface FunDef
    • getSignature

      public String getSignature()
      Description copied from interface: FunDef
      Returns an English description of the signature of the function, for example "<Numeric Expression> / <Numeric Expression>".
      Specified by:
      getSignature in interface FunDef
    • unparse

      public void unparse(Exp[] args, PrintWriter pw)
      Description copied from interface: FunDef
      Converts a function call into MDX source code.
      Specified by:
      unparse in interface FunDef