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.SQLTruncateStatement; 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.Boolean; 27 28 public class SQLTruncateStatement : SQLStatementImpl { 29 30 protected List!SQLExprTableSource tableSources; 31 32 private bool purgeSnapshotLog = false; 33 34 private bool only; 35 private Boolean restartIdentity; 36 private Boolean cascade; 37 38 // db2 39 private bool dropStorage = false; 40 private bool reuseStorage = false; 41 private bool immediate = false; 42 private bool ignoreDeleteTriggers = false; 43 private bool restrictWhenDeleteTriggers = false; 44 private bool continueIdentity = false; 45 46 public this(){ 47 tableSources = new ArrayList!SQLExprTableSource(2); 48 } 49 50 public this(string dbType){ 51 tableSources = new ArrayList!SQLExprTableSource(2); 52 super(dbType); 53 } 54 55 public List!SQLExprTableSource getTableSources() { 56 return tableSources; 57 } 58 59 public void setTableSources(List!SQLExprTableSource tableSources) { 60 this.tableSources = tableSources; 61 } 62 63 public void addTableSource(SQLName name) { 64 SQLExprTableSource tableSource = new SQLExprTableSource(name); 65 tableSource.setParent(this); 66 this.tableSources.add(tableSource); 67 } 68 69 70 override protected void accept0(SQLASTVisitor visitor) { 71 if (visitor.visit(this)) { 72 acceptChild!SQLExprTableSource(visitor, tableSources); 73 } 74 visitor.endVisit(this); 75 } 76 77 public bool isPurgeSnapshotLog() { 78 return purgeSnapshotLog; 79 } 80 81 public void setPurgeSnapshotLog(bool purgeSnapshotLog) { 82 this.purgeSnapshotLog = purgeSnapshotLog; 83 } 84 85 public bool isOnly() { 86 return only; 87 } 88 89 public void setOnly(bool only) { 90 this.only = only; 91 } 92 93 public Boolean getRestartIdentity() { 94 return restartIdentity; 95 } 96 97 public void setRestartIdentity(Boolean restartIdentity) { 98 this.restartIdentity = restartIdentity; 99 } 100 101 public Boolean getCascade() { 102 return cascade; 103 } 104 105 public void setCascade(Boolean cascade) { 106 this.cascade = cascade; 107 } 108 109 public bool isDropStorage() { 110 return dropStorage; 111 } 112 113 public void setDropStorage(bool dropStorage) { 114 this.dropStorage = dropStorage; 115 } 116 117 public bool isReuseStorage() { 118 return reuseStorage; 119 } 120 121 public void setReuseStorage(bool reuseStorage) { 122 this.reuseStorage = reuseStorage; 123 } 124 125 public bool isImmediate() { 126 return immediate; 127 } 128 129 public void setImmediate(bool immediate) { 130 this.immediate = immediate; 131 } 132 133 public bool isIgnoreDeleteTriggers() { 134 return ignoreDeleteTriggers; 135 } 136 137 public void setIgnoreDeleteTriggers(bool ignoreDeleteTriggers) { 138 this.ignoreDeleteTriggers = ignoreDeleteTriggers; 139 } 140 141 public bool isRestrictWhenDeleteTriggers() { 142 return restrictWhenDeleteTriggers; 143 } 144 145 public void setRestrictWhenDeleteTriggers(bool restrictWhenDeleteTriggers) { 146 this.restrictWhenDeleteTriggers = restrictWhenDeleteTriggers; 147 } 148 149 public bool isContinueIdentity() { 150 return continueIdentity; 151 } 152 153 public void setContinueIdentity(bool continueIdentity) { 154 this.continueIdentity = continueIdentity; 155 } 156 157 override 158 public List!SQLObject getChildren() { 159 return cast(List!SQLObject)tableSources; 160 } 161 }