001    /*
002    // $Id: //open/mondrian/src/main/mondrian/olap/FunDef.java#16 $
003    // This software is subject to the terms of the Common Public License
004    // Agreement, available at the following URL:
005    // http://www.opensource.org/licenses/cpl.html.
006    // Copyright (C) 1999-2002 Kana Software, Inc.
007    // Copyright (C) 2001-2006 Julian Hyde and others
008    // All Rights Reserved.
009    // You must accept the terms of that agreement to use this software.
010    //
011    // jhyde, 21 April, 1999
012    */
013    
014    package mondrian.olap;
015    
016    import mondrian.calc.Calc;
017    import mondrian.calc.ExpCompiler;
018    import mondrian.mdx.ResolvedFunCall;
019    
020    import java.io.PrintWriter;
021    
022    /**
023     * <code>FunDef</code> is the definition of an MDX function. See also {@link
024     * FunTable}.
025     */
026    public interface FunDef {
027        /**
028         * Returns the syntactic type of the function.
029         */
030        Syntax getSyntax();
031    
032        /**
033         * Returns the name of this function.
034         */
035        String getName();
036    
037        /**
038         * Returns the description of this function.
039         */
040        String getDescription();
041    
042        /**
043         * Returns the {@link Category} code of the value returned by this
044         * function.
045         */
046        int getReturnCategory();
047    
048        /**
049         * Returns the types of the arguments of this function. Values are the same
050         * as those returned by {@link Exp#getCategory()}. The 0<sup>th</sup>
051         * argument of methods and properties are the object they are applied
052         * to. Infix operators have two arguments, and prefix operators have one
053         * argument.
054         */
055        int[] getParameterCategories();
056    
057        /**
058         * Creates an expression which represents a call to this function with
059         * a given set of arguments. The result is usually a {@link ResolvedFunCall} but
060         * not always.
061         */
062        Exp createCall(Validator validator, Exp[] args);
063    
064        /**
065         * Returns an English description of the signature of the function, for
066         * example "&lt;Numeric Expression&gt; / &lt;Numeric Expression&gt;".
067         */
068        String getSignature();
069    
070        /**
071         * Converts a function call into MDX source code.
072         */
073        void unparse(Exp[] args, PrintWriter pw);
074    
075        /**
076         * Converts a call to this function into executable objects.
077         *
078         * <p>The result must implement the appropriate interface for the result
079         * type. For example, a function which returns an integer must return
080         * an object which implements {@link mondrian.calc.IntegerCalc}.
081         */
082        Calc compileCall(ResolvedFunCall call, ExpCompiler compiler);
083    
084    }
085    
086    // End FunDef.java