1 /* 2 * Copyright 2015-2018 HuntLabs.cn 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 module hunt.sql.ast.statement.SQLDropTableStatement; 17 18 19 import hunt.collection; 20 21 import hunt.sql.ast.SQLCommentHint; 22 import hunt.sql.ast.SQLName; 23 import hunt.sql.ast.SQLObject; 24 import hunt.sql.ast.SQLStatementImpl; 25 import hunt.sql.ast.expr.SQLPropertyExpr; 26 import hunt.sql.visitor.SQLASTVisitor; 27 import hunt.sql.ast.statement.SQLExprTableSource; 28 import hunt.sql.ast.statement.SQLDropStatement; 29 30 public class SQLDropTableStatement : SQLStatementImpl , SQLDropStatement { 31 private List!SQLCommentHint hints; 32 33 protected List!SQLExprTableSource tableSources; 34 35 private bool purge; 36 37 protected bool cascade = false; 38 protected bool restrict = false; 39 protected bool ifExists = false; 40 private bool temporary = false; 41 42 public this(){ 43 tableSources = new ArrayList!SQLExprTableSource(); 44 } 45 46 public this(string dbType){ 47 tableSources = new ArrayList!SQLExprTableSource(); 48 super (dbType); 49 } 50 51 public this(SQLName name, string dbType){ 52 tableSources = new ArrayList!SQLExprTableSource(); 53 this(new SQLExprTableSource(name), dbType); 54 } 55 56 public this(SQLName name){ 57 this (name, string.init); 58 } 59 60 public this(SQLExprTableSource tableSource){ 61 this(tableSource, string.init); 62 } 63 64 public this(SQLExprTableSource tableSource, string dbType){ 65 this (dbType); 66 this.tableSources.add(tableSource); 67 } 68 69 public List!SQLExprTableSource getTableSources() { 70 return tableSources; 71 } 72 73 public void addPartition(SQLExprTableSource tableSource) { 74 if (tableSource !is null) { 75 tableSource.setParent(this); 76 } 77 this.tableSources.add(tableSource); 78 } 79 80 public void setName(SQLName name) { 81 this.addTableSource(new SQLExprTableSource(name)); 82 } 83 84 public void addTableSource(SQLName name) { 85 this.addTableSource(new SQLExprTableSource(name)); 86 } 87 88 public void addTableSource(SQLExprTableSource tableSource) { 89 tableSources.add(tableSource); 90 } 91 92 93 override protected void accept0(SQLASTVisitor visitor) { 94 if (visitor.visit(this)) { 95 this.acceptChild!SQLExprTableSource(visitor, tableSources); 96 } 97 visitor.endVisit(this); 98 } 99 100 override 101 public List!SQLObject getChildren() { 102 return cast(List!SQLObject)this.tableSources; 103 } 104 105 public bool isPurge() { 106 return purge; 107 } 108 109 public void setPurge(bool purge) { 110 this.purge = purge; 111 } 112 113 public bool isIfExists() { 114 return ifExists; 115 } 116 117 public void setIfExists(bool ifExists) { 118 this.ifExists = ifExists; 119 } 120 121 public bool isCascade() { 122 return cascade; 123 } 124 125 public void setCascade(bool cascade) { 126 this.cascade = cascade; 127 } 128 129 public bool isRestrict() { 130 return restrict; 131 } 132 133 public void setRestrict(bool restrict) { 134 this.restrict = restrict; 135 } 136 137 public bool isTemporary() { 138 return temporary; 139 } 140 141 public void setTemporary(bool temporary) { 142 this.temporary = temporary; 143 } 144 145 public List!SQLCommentHint getHints() { 146 return hints; 147 } 148 149 public void setHints(List!SQLCommentHint hints) { 150 this.hints = hints; 151 } 152 }