001package gudusoft.gsqlparser.nodes;
002/*
003 * Date: 2010-12-22
004 * Time: 14:33:43
005 */
006
007import gudusoft.gsqlparser.ESqlClause;
008import gudusoft.gsqlparser.TCustomSqlStatement;
009
010import java.util.ArrayList;
011
012/**
013 * represents values() clause. {@link #getRows()} returns the rows in this value clause.
014 */
015public class TValueClause extends TParseTreeNode {
016    private TValueRowItemList valueRows = null;
017    private TObjectNameList  nameList  = null;
018
019    public TObjectNameList getNameList() {
020        return nameList;
021    }
022
023    /**
024     * @deprecated As of v2.3.6.9, please use {@link #getRows()} instead
025     * The first row of the value clause.
026     *
027     * @return The first row of the value clause.
028     */
029    public TValueRowItemList getValueRows() {
030        return valueRows;//rows.get(0);
031    }
032
033
034
035    /**
036     * Rows in the values clause.
037     * @return Rows in the values clause.
038     */
039    public ArrayList<TResultColumnList> getRows() {
040        return rows;
041    }
042
043    private ArrayList <TResultColumnList> rows = new ArrayList<>();
044
045    public void  append(TResultColumnList list){
046        rows.add(list);
047    }
048
049    public void init(Object arg1)
050    {
051        if (arg1 instanceof TValueRowItemList){
052            valueRows = (TValueRowItemList)arg1;
053
054        }else if (arg1 instanceof TResultColumnList){
055            append((TResultColumnList)arg1);
056        }
057
058    }
059
060    public void init(Object arg1,Object arg2)
061    {
062        init(arg1);
063        if (arg2 != null){
064            nameList = (TObjectNameList)arg2;
065        }
066    }
067
068    public void doParse(TCustomSqlStatement psql, ESqlClause plocation){
069        //for(int i=0;i<rows.size();i++){
070            for(TResultColumnList item:rows){
071                item.doParse(psql,plocation);
072            }
073        //}
074    }
075
076    public void accept(TParseTreeVisitor v){
077        v.preVisit(this);
078        v.postVisit(this);
079    }
080
081    public void acceptChildren(TParseTreeVisitor v){
082        v.preVisit(this);
083        for(int i=0;i<rows.size();i++){
084            rows.get(i).acceptChildren(v);
085        }
086        v.postVisit(this);
087    }
088
089    public void setValueRows(TValueRowItemList valueRows) {
090        this.valueRows = valueRows;
091    }
092
093    public void setNameList(TObjectNameList nameList) {
094        this.nameList = nameList;
095    }
096}