001package gudusoft.gsqlparser.nodes;
002
003
004import gudusoft.gsqlparser.ESqlClause;
005import gudusoft.gsqlparser.TCustomSqlStatement;
006
007/**
008 * used in window function
009 *
010 */
011public class TPartitionClause extends TParseTreeNode {
012
013    private  TExpressionList expressionList;
014    private TOrderByItemList sortedColumns = null;
015
016    /**
017     * sorted column list, should be replaced by {@link #getSortedColumns()}, it is used for backward compatibility only
018     *
019     * @return sorted column list
020     */
021    public TExpressionList getExpressionList() {
022        return expressionList;
023    }
024
025    public  void init(Object arg1){
026        if (arg1 instanceof TOrderByItemList){
027            sortedColumns = (TOrderByItemList)arg1;
028        }else if (arg1 instanceof TExpressionList){
029            this.expressionList = (TExpressionList)arg1;
030        }
031
032    }
033
034    public void setExpressionList(TExpressionList expressionList) {
035        this.expressionList = expressionList;
036    }
037
038    /**
039     * sorted column list
040     *
041     * @return sorted column list
042     */
043    public TOrderByItemList getSortedColumns() {
044        return sortedColumns;
045    }
046
047    public void doParse(TCustomSqlStatement psql, ESqlClause plocation){
048        if (sortedColumns != null){
049            sortedColumns.doParse(psql,plocation);
050        }else if (expressionList != null){
051            expressionList.doParse(psql,plocation);
052        }
053    }
054
055    public void accept(TParseTreeVisitor v){
056        v.preVisit(this);
057        v.postVisit(this);
058    }
059
060    public void acceptChildren(TParseTreeVisitor v){
061        v.preVisit(this);
062        if (sortedColumns != null){
063            sortedColumns.acceptChildren(v);
064        }else if (expressionList != null){
065            expressionList.acceptChildren(v);
066        }
067        v.postVisit(this);
068    }
069}