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.SQLDropViewStatement; 17 18 19 import hunt.collection; 20 21 import hunt.sql.ast.SQLName; 22 import hunt.sql.ast.SQLObject; 23 import hunt.sql.ast.SQLStatementImpl; 24 import hunt.sql.visitor.SQLASTVisitor; 25 import hunt.sql.ast.statement.SQLExprTableSource; 26 import hunt.sql.ast.statement.SQLDropStatement; 27 28 public class SQLDropViewStatement : SQLStatementImpl , SQLDropStatement { 29 30 protected List!SQLExprTableSource tableSources; 31 32 protected bool cascade = false; 33 protected bool restrict = false; 34 protected bool ifExists = false; 35 36 public this(){ 37 tableSources = new ArrayList!SQLExprTableSource(); 38 } 39 40 public this(string dbType){ 41 super (dbType); 42 } 43 44 public this(SQLName name){ 45 this(new SQLExprTableSource(name)); 46 } 47 48 public this(SQLExprTableSource tableSource){ 49 this.tableSources.add(tableSource); 50 } 51 52 public List!SQLExprTableSource getTableSources() { 53 return tableSources; 54 } 55 56 public void addPartition(SQLExprTableSource tableSource) { 57 if (tableSource !is null) { 58 tableSource.setParent(this); 59 } 60 this.tableSources.add(tableSource); 61 } 62 63 public void setName(SQLName name) { 64 this.addTableSource(new SQLExprTableSource(name)); 65 } 66 67 public void addTableSource(SQLName name) { 68 this.addTableSource(new SQLExprTableSource(name)); 69 } 70 71 public void addTableSource(SQLExprTableSource tableSource) { 72 tableSources.add(tableSource); 73 } 74 75 public bool isCascade() { 76 return cascade; 77 } 78 79 public void setCascade(bool cascade) { 80 this.cascade = cascade; 81 } 82 83 84 override protected void accept0(SQLASTVisitor visitor) { 85 if (visitor.visit(this)) { 86 this.acceptChild!SQLExprTableSource(visitor, tableSources); 87 } 88 visitor.endVisit(this); 89 } 90 91 public bool isRestrict() { 92 return restrict; 93 } 94 95 public void setRestrict(bool restrict) { 96 this.restrict = restrict; 97 } 98 99 public bool isIfExists() { 100 return ifExists; 101 } 102 103 public void setIfExists(bool ifExists) { 104 this.ifExists = ifExists; 105 } 106 107 override 108 public List!SQLObject getChildren() { 109 return cast(List!SQLObject)tableSources; 110 } 111 }