001package gudusoft.gsqlparser.nodes;
002
003import gudusoft.gsqlparser.ESqlClause;
004import gudusoft.gsqlparser.TCustomSqlStatement;
005
006/**
007 * The ROLLUP operation in the simple_grouping_clause groups the selected rows based on the values of the first n, n-1, n-2, ... 0 expressions in the GROUP
008 * BY specification, and returns a single row of summary for each group.
009 *
010 * <p>The CUBE operation in the simple_grouping_clause groups the selected rows based on the values of all possible combinations of expressions in the specification.
011 * It returns a single row of summary information for each group.
012*/
013public class TRollupCube extends TParseTreeNode {
014
015    public final static int     rollup = 1;
016    public final static int     cube = 2;
017
018    private int operation = rollup;
019
020    public void setOperation(int operation) {
021        this.operation = operation;
022    }
023
024    /**
025     * @return rollup or cube operation.
026     */
027    public int getOperation() {
028
029        return operation;
030    }
031
032    /**
033     *
034     * @return grouping expression list
035     * @see TExpressionList
036     */
037    public TExpressionList getItems() {
038        return items;
039    }
040
041    private TExpressionList items = null;
042    
043    public void init(Object arg1)
044    {
045       items = (TExpressionList)arg1;
046    }
047
048    public void doParse(TCustomSqlStatement psql, ESqlClause plocation){
049        if (items != null){
050            items.doParse(psql,plocation);
051        }
052    }
053
054    public void accept(TParseTreeVisitor v){
055        v.preVisit(this);
056        v.postVisit(this);
057    }
058
059    public void acceptChildren(TParseTreeVisitor v){
060        v.preVisit(this);
061        v.postVisit(this);
062    }
063
064    public void setItems(TExpressionList items) {
065        this.items = items;
066    }
067}