|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.xom.XMLUtil org.eigenbase.xom.XOMUtil mondrian.olap.Util mondrian.olap.fun.FunUtil mondrian.olap.fun.FunDefBase
public abstract class FunDefBase
FunDefBase
is the default implementation of FunDef
.
A function is defined by the following:
Parameter | Meaning | Example |
---|---|---|
name | Name 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" |
flags
field is an string which encodes
the syntactic type, return type, and parameter types of this operator.
FunUtil.decodeSyntacticType(String)
.
FunUtil.decodeReturnCategory(String)
.
FunUtil.decodeParameterCategories(String)
.
"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).
Nested Class Summary |
---|
Nested classes/interfaces inherited from class mondrian.olap.fun.FunUtil |
---|
FunUtil.SetWrapper |
Nested classes/interfaces inherited from class mondrian.olap.Util |
---|
Util.ErrorCellValue, Util.PropertyList |
Field Summary | |
---|---|
protected int |
flags
|
protected int[] |
parameterCategories
|
protected int |
returnCategory
|
(package private) String |
signature
|
Fields inherited from class mondrian.olap.fun.FunUtil |
---|
BooleanNull, DoubleEmpty, DoubleNull, emptyStringArray, IntegerNull, NullMember |
Fields inherited from class mondrian.olap.Util |
---|
EmptyValue, JdbcVersion, nl, nullValue, PreJdk15, Retrowoven |
Constructor Summary | |
---|---|
(package private) |
FunDefBase(FunDef funDef)
Copy constructor. |
(package private) |
FunDefBase(Resolver resolver,
int returnType,
int[] parameterTypes)
Convenience constructor when we are created by a Resolver . |
protected |
FunDefBase(String name,
String description,
String flags)
Creates an operator. |
protected |
FunDefBase(String name,
String signature,
String description,
String flags)
Creates an operator with an explicit signature. |
(package private) |
FunDefBase(String name,
String signature,
String description,
Syntax syntax,
int returnCategory,
int[] parameterCategories)
Creates an operator. |
Method Summary | |
---|---|
(package private) static Type |
castType(Type type,
int category)
Converts a type to a different category, maintaining as much type information as possible. |
Calc |
compileCall(ResolvedFunCall call,
ExpCompiler compiler)
Converts a call to this function into executable objects. |
Exp |
createCall(Validator validator,
Exp[] args)
Creates an expression which represents a call to this function with a given set of arguments. |
String |
getDescription()
Returns the description of this function. |
String |
getName()
Returns the name of this function. |
int[] |
getParameterCategories()
Returns the types of the arguments of this function. |
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. |
int |
getReturnCategory()
Returns the Category code of the value returned by this
function. |
String |
getSignature()
Returns an English description of the signature of the function, for example "<Numeric Expression> / <Numeric Expression>". |
Syntax |
getSyntax()
Returns the syntactic type of the function. |
void |
unparse(Exp[] args,
PrintWriter pw)
Converts a function call into MDX source code. |
protected Exp |
validateArg(Validator validator,
Exp[] args,
int i,
int category)
Validates an argument to a call to this function. |
Methods inherited from class org.eigenbase.xom.XOMUtil |
---|
addAll, addAll, addChild, addChild, addChildren, addElement, concatenate, createDefaultParser, discard, discard, discard, discard, discard, discard, discard, discard, discard, getFirstInstance, toList, toVector, wrapperToXml |
Methods inherited from class org.eigenbase.xom.XMLUtil |
---|
getFirstTagName, printAtt, printAtt, printAtt, printAtt, printPCDATA, printPCDATA, printPCDATA, quoteAtt, quoteAtt, quoteAtt, quoteAtt, quotePCDATA, stringEncodeXML, stringHasXMLSpecials |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final int flags
final String signature
protected final int returnCategory
protected final int[] parameterCategories
Constructor Detail |
---|
FunDefBase(String name, String signature, String description, Syntax syntax, int returnCategory, int[] parameterCategories)
name
- Name of the function, for example "Members".signature
- Signature of the function, for example
"<Dimension>.Members".description
- Description of the function, for example
"Returns the set of all members in a dimension."syntax
- Syntactic type of the operator (for example, function,
method, infix operator)returnCategory
- The Category
of the value returned by this
operator.parameterCategories
- An array of Category
codes, one for
each parameter.protected FunDefBase(String name, String description, String flags)
name
- Name of the function, for example "Members".description
- Description of the function, for example
"Returns the set of all members in a dimension."flags
- Encoding of the syntactic type, return type, and parameter
types of this operator. The "Members" operator has a syntactic
type "pxd" which means "an operator with
property
syntax (p) which returns a set
(x) and takes a dimension (d) as its argument".
See FunUtil.decodeSyntacticType(String)
,
FunUtil.decodeReturnCategory(String)
,
FunUtil.decodeParameterCategories(String)
.protected FunDefBase(String name, String signature, String description, String flags)
In most cases, the signature can be generated automatically, and
you should use the constructor which creates an implicit signature,
FunDefBase(String, String, String, String)
instead.
name
- Name of the function, for example "Members".signature
- Signature of the function, for example
"<Dimension>.Members".description
- Description of the function, for example
"Returns the set of all members in a dimension."flags
- Encoding of the syntactic type, return type, and parameter
types of this operator. The "Members" operator has a syntactic
type "pxd" which means "an operator with
property
syntax (p) which returns a set
(x) and takes a dimension (d) as its argument".
See FunUtil.decodeSyntacticType(String)
,
FunUtil.decodeReturnCategory(String)
,
FunUtil.decodeParameterCategories(String)
.FunDefBase(Resolver resolver, int returnType, int[] parameterTypes)
Resolver
.
resolver
- ResolverreturnType
- Return typeparameterTypes
- Parameter typesFunDefBase(FunDef funDef)
funDef
- Function definition to copyMethod Detail |
---|
public String getName()
FunDef
getName
in interface FunDef
public String getDescription()
FunDef
getDescription
in interface FunDef
public Syntax getSyntax()
FunDef
getSyntax
in interface FunDef
public int getReturnCategory()
FunDef
Category
code of the value returned by this
function.
getReturnCategory
in interface FunDef
public int[] getParameterCategories()
FunDef
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.
getParameterCategories
in interface FunDef
public Exp createCall(Validator validator, Exp[] args)
FunDef
ResolvedFunCall
but
not always.
createCall
in interface FunDef
protected Exp validateArg(Validator validator, Exp[] args, int i, int category)
The default implementation of this method adds an implicit conversion to the correct type. Derived classes may override.
validator
- Validatorargs
- Arguments to this functioni
- Ordinal of argumentcategory
- Expected category
of argument
static Type castType(Type type, int category)
LevelType(dimension=Time, hierarchy=unknown,
level=unkown)
and category=Hierarchy, returns
HierarchyType(dimension=Time)
.
type
- Typecategory
- Desired category
public Type getResultType(Validator validator, Exp[] args)
validator
- Validatorargs
- Arguments to the call to this operator
public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler)
FunDef
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
.
compileCall
in interface FunDef
public String getSignature()
FunDef
getSignature
in interface FunDef
public void unparse(Exp[] args, PrintWriter pw)
FunDef
unparse
in interface FunDef
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |