public abstract class FunDefBase extends FunUtil implements FunDef
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).FunUtil.DescendingValueComparator, FunUtil.ObjIntPair<T>, FunUtil.OrderKey
Util.AbstractFlatList<T>, Util.ByteMatcher, Util.ErrorCellValue, Util.Flat2List<T>, Util.Flat3List<T>, Util.Functor1<RT,PT>, Util.GcIterator<T>, Util.MemoryInfo, Util.PropertyList, Util.SqlNullSafeComparator
Modifier and Type | Field and Description |
---|---|
protected int |
flags |
protected int[] |
parameterCategories |
protected int |
returnCategory |
BooleanNull, DoubleEmpty, DoubleNull, IntegerNull, NullMember
DEBUG, EmptyValue, IBM_JVM, JdbcVersion, JVM_INSTANCE_UUID, nl, nullValue, Retrowoven
Modifier | Constructor and Description |
---|---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
avg, box, box, checkIterListResultStyles, checkListResultStyles, compareHierarchically, compareSiblingMembers, compareValues, compareValues, count, decodeCategory, decodeParameterCategories, decodeReturnCategory, decodeSyntacticType, getDimensionDefaultHierarchy, getNonEmptyMemberChildren, getNonEmptyMemberChildrenWithDetails, hierarchizeMemberList, hierarchizeTupleList, makeNullTuple, max, min, newEvalException, newEvalException, newEvalException, partiallySortMembers, partiallySortTuples, quartile, resolveFunArgs, sortTuples, stablePartialSort, stablePartialSort, stablePartialSortArray, stablePartialSortJulian, stablePartialSortMarc, stablePartialSortPedro, sum, sumDouble, sumDouble, tupleContainsNullMember, tupleContainsNullMember, worthCaching
addDatabaseTime, addLevelCalculatedMembers, append, appendArrays, areOccurencesEqual, assertPostcondition, assertPostcondition, assertPrecondition, assertPrecondition, assertTrue, assertTrue, badValue, binarySearch, bitSetBetween, camelToUpper, canCast, cancelStatement, caseSensitiveCompareName, cast, cast, castToIterable, checkCJResultLimit, close, commaList, compare, compareIntegers, compareKey, compareName, compileScript, convert, convert, convertOlap4jConnectStringToNativeMondrian, convertStackToString, copyOf, copyOf, copyOf, copyOf, copyOf, createExpr, createRandom, createRootRole, createSimpleValidator, createUdf, dbTimeMillis, deprecated, deprecated, digestMd5, digestSha256, equal, equalName, equals, equals, falseFunctor, filter, flatList, flatList, flatListCopy, generateUuidString, genericArray, getAnnotation, getClosestResource, getDimensionCube, getErrorMessage, getErrorMessage, getExecutorService, getFirstDescendantOnLevel, getMatchingCause, getMemberOrdinalInParent, getMembersToHierarchyMap, getMemoryInfo, getScheduledExecutorService, hash, hash, hashArray, identityFunctor, implode, intersect, isBlank, isEmpty, isNull, isSorted, isValidProperty, last, lookup, lookup, lookup, lookup, lookup, lookupCompound, lookupCompound, lookupHierarchyLevel, lookupHierarchyRootMember, lookupHierarchyRootMember, lookupProperty, makeBigDecimalFromDouble, makeFqName, makeFqName, makeFqName, matches, matches, mdxEncodeString, needToImplement, newElementNotFoundException, newError, newError, newIdentityHashSet, newIdentityHashSetFake, newInternal, newInternal, newTimer, nonDbTimeMillis, normalizeName, only, parseCommaList, parseConnectString, parseIdentifier, parseInterval, parseLocale, printMemory, printMemory, quoteForMdx, quoteForMdx, quoteJavaString, quoteMdxIdentifier, quoteMdxIdentifier, quoteMdxIdentifier, quoteMdxIdentifier, quotePattern, readFully, readFully, readURL, readURL, readURL, readVirtualFile, readVirtualFileAsString, replace, replace, replaceProperties, safeGet, singleQuoteString, singleQuoteString, sort, sort, threadLocalRemove, toMap, toNullValuesMap, toOlap4j, toOlap4j, toOlap4j, toURL, trueFunctor, unexpected, uniquify, unparse, unparse, wildcardToRegexp
addChild, addChild, addChildren, addElement, concatenate, createDefaultParser, discard, discard, discard, discard, discard, discard, discard, discard, discard, getFirstInstance, wrapperToXml
protected final int flags
protected final int returnCategory
protected final int[] parameterCategories
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)
.public String getName()
FunDef
public String getDescription()
FunDef
getDescription
in interface FunDef
public Syntax getSyntax()
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 argumentpublic Type getResultType(Validator validator, Exp[] args)
validator
- Validatorargs
- Arguments to the call to this operatorpublic 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
Copyright © 2020 Hitachi Vantara. All rights reserved.