001package gudusoft.gsqlparser.nodes.mdx;
002/*
003 * Date: 12-1-31
004 */
005
006import gudusoft.gsqlparser.nodes.TPTNodeList;
007import gudusoft.gsqlparser.nodes.TParseTreeVisitor;
008
009/**
010 * MDX function or method.
011 * <br> When it represents a method, the first element of {@link #getArguments()} is the object expression
012 * and the real arguments is start from the second element.
013 * <br>
014 * <br> This is a method: Set_Expression.Item(Index), {@link #getFunctionName()} returns Item,
015 * the first element of {@link #getArguments} returns Set_Expression while the second element is Index
016 * <br>
017 * <br> This is a function: Median(Set_Expression [ ,Numeric_Expression ] ) ,
018 * {@link #getFunctionName()} returns Median, the first element of {@link #getArguments} returns Set_Expression
019 *
020 */
021public class TMdxFunctionNode extends TMdxBaseFunctionNode {
022
023    private String functionName;
024    private TPTNodeList<TMdxExpNode> arguments;
025    private IMdxIdentifierSegment functionSegment;
026    private EMdxExpSyntax   expSyntax;
027
028    public void TMdxFunctionNode(){
029        arguments = new  TPTNodeList<TMdxExpNode> ();
030    }
031
032    public void init(Object arg1, Object arg2,Object arg3){
033       this.arguments =  (TPTNodeList<TMdxExpNode>) arg1;
034       this.functionSegment = (IMdxIdentifierSegment)arg2;
035       this.expSyntax = (EMdxExpSyntax)arg3;
036    }
037
038
039    public String getFunctionName(){
040        return functionSegment.getName();
041    };
042
043    public IMdxIdentifierSegment getFunctionSegment(){
044        return functionSegment;
045    };
046
047    /**
048     *  If this class represents a method, the first element is the object expression of the method,
049     * and the real argument is start from the second element.
050     *
051     * @return argument of function or method.
052     */
053    public  TPTNodeList<TMdxExpNode> getArguments(){
054        return arguments;
055    };
056
057    public EMdxDataType getMdxDataType(){
058        return EMdxDataType.Unknown;
059    }
060
061    public EMdxExpSyntax getExpSyntax(){
062        return expSyntax;
063    };
064
065    public void accept(TParseTreeVisitor v){
066        v.preVisit(this);
067        v.postVisit(this);
068    }
069
070    public void acceptChildren(TParseTreeVisitor v){
071        v.preVisit(this);
072        if (arguments != null){
073            arguments.accept(v);
074        }
075        v.postVisit(this);
076    }
077}