package com.chenyang.druid.sql.ast.statement;

import com.chenyang.druid.sql.ast.SQLExpr;
import com.chenyang.druid.sql.ast.SQLName;
import com.chenyang.druid.sql.ast.SQLStatementImpl;
import com.chenyang.druid.sql.ast.expr.SQLIdentifierExpr;
import com.chenyang.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;

public class SQLOpenStatement extends SQLStatementImpl {
   private SQLName cursorName;
   private final List<SQLName> columns = new ArrayList();
   private SQLExpr forExpr;
   private final List<SQLExpr> using = new ArrayList();

   public SQLName getCursorName() {
      return this.cursorName;
   }

   public void setCursorName(String cursorName) {
      this.setCursorName((SQLName)(new SQLIdentifierExpr(cursorName)));
   }

   public void setCursorName(SQLName cursorName) {
      if (cursorName != null) {
         cursorName.setParent(this);
      }

      this.cursorName = cursorName;
   }

   protected void accept0(SQLASTVisitor visitor) {
      if (visitor.visit(this)) {
         this.acceptChild(visitor, this.cursorName);
         this.acceptChild(visitor, this.forExpr);
         this.acceptChild(visitor, this.columns);
      }

      visitor.endVisit(this);
   }

   public SQLExpr getFor() {
      return this.forExpr;
   }

   public void setFor(SQLExpr forExpr) {
      if (forExpr != null) {
         forExpr.setParent(this);
      }

      this.forExpr = forExpr;
   }

   public List<SQLName> getColumns() {
      return this.columns;
   }

   public List<SQLExpr> getUsing() {
      return this.using;
   }
}
