content: package com.alibaba.druid.sql.ast.statement;
  
  import com.alibaba.druid.sql.ast.SQLExpr;
  import com.alibaba.druid.sql.ast.SQLObjectImpl;
  import com.alibaba.druid.sql.ast.SQLStatement;
  import com.alibaba.druid.sql.ast.SQLStatementImpl;
  import com.alibaba.druid.sql.visitor.SQLASTVisitor;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class SQLExceptionStatement extends SQLStatementImpl {
      // TODO: merge with OracleExceptionStatement
      private List<Item> items = new ArrayList<>();
  
      public List<Item> getItems() {
          return items;
      }
  
      public void addItem(Item item) {
          if (item != null) {
              item.setParent(this);
          }
  
          this.items.add(item);
      }
  
      @Override
      protected void accept0(SQLASTVisitor v) {
          if (v.visit(this)) {
              acceptChild(v, items);
          }
          v.endVisit(this);
      }
  
      public static class Item extends SQLObjectImpl {
          private SQLExpr when;
          private List<SQLStatement> statements = new ArrayList<SQLStatement>();
  
          public SQLExpr getWhen() {
              return when;
          }
  
          public void setWhen(SQLExpr when) {
              this.when = when;
          }
  
          public List<SQLStatement> getStatements() {
              return statements;
          }
  
          public void setStatement(SQLStatement statement) {
              if (statement != null) {
                  statement.setParent(this);
                  this.statements.add(statement);
              }
          }
  
          @Override
          public void accept0(SQLASTVisitor visitor) {
              if (visitor.visit(this)) {
                  acceptChild(visitor, when);
                  acceptChild(visitor, statements);
              }
              visitor.endVisit(this);
          }
  
          public Item clone() {
              Item x = new Item();
              if (when != null) {
                  x.setWhen(when.clone());
              }
              for (SQLStatement stmt : statements) {
                  SQLStatement stmt2 = stmt.clone();
                  stmt2.setParent(x);
                  x.statements.add(stmt2);
              }
              return x;
          }
      }
  }
  