package com.alibaba.druid.sql.dialect.oracle.ast.stmt;

import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.ast.statement.SQLForStatement;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;

public class OracleForStatement extends SQLForStatement implements OracleStatement {
   private boolean all;
   private SQLName endLabel;

   protected void accept0(SQLASTVisitor v) {
      if (v instanceof OracleASTVisitor) {
         this.accept0((OracleASTVisitor)v);
      } else {
         super.accept0(v);
      }
   }

   public void accept0(OracleASTVisitor v) {
      if (v.visit(this)) {
         this.acceptChild(v, this.index);
         this.acceptChild(v, this.range);
         this.acceptChild(v, this.statements);
      }

      v.endVisit(this);
   }

   public boolean isAll() {
      return this.all;
   }

   public void setAll(boolean all) {
      this.all = all;
   }

   public SQLName getEndLabel() {
      return this.endLabel;
   }

   public void setEndLabel(SQLName endLabel) {
      if (endLabel != null) {
         endLabel.setParent(this);
      }

      this.endLabel = endLabel;
   }

   public OracleForStatement clone() {
      OracleForStatement x = new OracleForStatement();
      if (this.index != null) {
         x.setIndex(this.index.clone());
      }

      if (this.range != null) {
         x.setRange(this.range.clone());
      }

      for(SQLStatement stmt : this.statements) {
         SQLStatement stmt2 = stmt.clone();
         stmt2.setParent(x);
         x.statements.add(stmt2);
      }

      x.all = this.all;
      if (this.endLabel != null) {
         x.setEndLabel(this.endLabel.clone());
      }

      return x;
   }
}
