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
027
028        if (arg1 instanceof TOrderByItemList){
029            sortedColumns = (TOrderByItemList)arg1;
030        }else if (arg1 instanceof TExpressionList){
031            this.expressionList = (TExpressionList)arg1;
032        }
033
034    }
035
036    public void setExpressionList(TExpressionList expressionList) {
037        this.expressionList = expressionList;
038    }
039
040    /**
041     * sorted column list
042     *
043     * @return sorted column list
044     */
045    public TOrderByItemList getSortedColumns() {
046        return sortedColumns;
047    }
048
049    public void doParse(TCustomSqlStatement psql, ESqlClause plocation){
050        if (sortedColumns != null){
051            sortedColumns.doParse(psql,plocation);
052        }else if (expressionList != null){
053            expressionList.doParse(psql,plocation);
054        }
055    }
056
057    public void accept(TParseTreeVisitor v){
058        v.preVisit(this);
059        v.postVisit(this);
060    }
061
062    public void acceptChildren(TParseTreeVisitor v){
063        v.preVisit(this);
064        if (sortedColumns != null){
065            sortedColumns.acceptChildren(v);
066        }else if (expressionList != null){
067            expressionList.acceptChildren(v);
068        }
069        v.postVisit(this);
070    }
071}