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.dialect.mysql.ast.statement.MySqlLoadDataInFileStatement; 17 18 19 import hunt.collection; 20 21 import hunt.sql.ast.SQLExpr; 22 import hunt.sql.ast.SQLName; 23 import hunt.sql.ast.SQLObject; 24 import hunt.sql.ast.expr.SQLLiteralExpr; 25 import hunt.sql.dialect.mysql.visitor.MySqlASTVisitor; 26 import hunt.sql.dialect.mysql.ast.statement.MySqlStatementImpl; 27 28 public class MySqlLoadDataInFileStatement : MySqlStatementImpl { 29 30 alias accept0 = MySqlStatementImpl.accept0; 31 32 private bool lowPriority = false; 33 private bool concurrent = false; 34 private bool local = false; 35 36 private SQLLiteralExpr fileName; 37 38 private bool replicate = false; 39 private bool ignore = false; 40 41 private SQLName tableName; 42 43 private string charset; 44 45 private SQLLiteralExpr columnsTerminatedBy; 46 private bool columnsEnclosedOptionally = false; 47 private SQLLiteralExpr columnsEnclosedBy; 48 private SQLLiteralExpr columnsEscaped; 49 50 private SQLLiteralExpr linesStartingBy; 51 private SQLLiteralExpr linesTerminatedBy; 52 53 private SQLExpr ignoreLinesNumber; 54 55 private List!(SQLExpr) setList; 56 57 private List!(SQLExpr) columns; 58 59 this(){ 60 setList = new ArrayList!(SQLExpr)(); 61 columns = new ArrayList!(SQLExpr)(); 62 } 63 64 public bool isLowPriority() { 65 return lowPriority; 66 } 67 68 public void setLowPriority(bool lowPriority) { 69 this.lowPriority = lowPriority; 70 } 71 72 public bool isConcurrent() { 73 return concurrent; 74 } 75 76 public void setConcurrent(bool concurrent) { 77 this.concurrent = concurrent; 78 } 79 80 public bool isLocal() { 81 return local; 82 } 83 84 public void setLocal(bool local) { 85 this.local = local; 86 } 87 88 public SQLLiteralExpr getFileName() { 89 return fileName; 90 } 91 92 public void setFileName(SQLLiteralExpr fileName) { 93 this.fileName = fileName; 94 } 95 96 public bool isReplicate() { 97 return replicate; 98 } 99 100 public void setReplicate(bool replicate) { 101 this.replicate = replicate; 102 } 103 104 public bool isIgnore() { 105 return ignore; 106 } 107 108 public void setIgnore(bool ignore) { 109 this.ignore = ignore; 110 } 111 112 public SQLName getTableName() { 113 return tableName; 114 } 115 116 public void setTableName(SQLName tableName) { 117 this.tableName = tableName; 118 } 119 120 public string getCharset() { 121 return charset; 122 } 123 124 public void setCharset(string charset) { 125 this.charset = charset; 126 } 127 128 public SQLLiteralExpr getColumnsTerminatedBy() { 129 return columnsTerminatedBy; 130 } 131 132 public void setColumnsTerminatedBy(SQLLiteralExpr columnsTerminatedBy) { 133 this.columnsTerminatedBy = columnsTerminatedBy; 134 } 135 136 public bool isColumnsEnclosedOptionally() { 137 return columnsEnclosedOptionally; 138 } 139 140 public void setColumnsEnclosedOptionally(bool columnsEnclosedOptionally) { 141 this.columnsEnclosedOptionally = columnsEnclosedOptionally; 142 } 143 144 public SQLLiteralExpr getColumnsEnclosedBy() { 145 return columnsEnclosedBy; 146 } 147 148 public void setColumnsEnclosedBy(SQLLiteralExpr columnsEnclosedBy) { 149 this.columnsEnclosedBy = columnsEnclosedBy; 150 } 151 152 public SQLLiteralExpr getColumnsEscaped() { 153 return columnsEscaped; 154 } 155 156 public void setColumnsEscaped(SQLLiteralExpr columnsEscaped) { 157 this.columnsEscaped = columnsEscaped; 158 } 159 160 public SQLLiteralExpr getLinesStartingBy() { 161 return linesStartingBy; 162 } 163 164 public void setLinesStartingBy(SQLLiteralExpr linesStartingBy) { 165 this.linesStartingBy = linesStartingBy; 166 } 167 168 public SQLLiteralExpr getLinesTerminatedBy() { 169 return linesTerminatedBy; 170 } 171 172 public void setLinesTerminatedBy(SQLLiteralExpr linesTerminatedBy) { 173 this.linesTerminatedBy = linesTerminatedBy; 174 } 175 176 public SQLExpr getIgnoreLinesNumber() { 177 return ignoreLinesNumber; 178 } 179 180 public void setIgnoreLinesNumber(SQLExpr ignoreLinesNumber) { 181 this.ignoreLinesNumber = ignoreLinesNumber; 182 } 183 184 public List!(SQLExpr) getSetList() { 185 return setList; 186 } 187 188 override public void accept0(MySqlASTVisitor visitor) { 189 if (visitor.visit(this)) { 190 acceptChild(visitor, fileName); 191 acceptChild(visitor, tableName); 192 acceptChild(visitor, columnsTerminatedBy); 193 acceptChild(visitor, columnsEnclosedBy); 194 acceptChild(visitor, columnsEscaped); 195 acceptChild(visitor, linesStartingBy); 196 acceptChild(visitor, linesTerminatedBy); 197 acceptChild(visitor, ignoreLinesNumber); 198 acceptChild(visitor, cast(List!(SQLObject))setList); 199 } 200 visitor.endVisit(this); 201 } 202 203 override 204 public List!(SQLObject) getChildren() { 205 List!(SQLObject) children = new ArrayList!(SQLObject)(); 206 if (fileName !is null) { 207 children.add(fileName); 208 } 209 if (tableName !is null) { 210 children.add(tableName); 211 } 212 if (columnsTerminatedBy !is null) { 213 children.add(columnsTerminatedBy); 214 } 215 if (columnsEnclosedBy !is null) { 216 children.add(columnsEnclosedBy); 217 } 218 if (columnsEscaped !is null) { 219 children.add(columnsEscaped); 220 } 221 if (linesStartingBy !is null) { 222 children.add(linesStartingBy); 223 } 224 if (linesTerminatedBy !is null) { 225 children.add(linesTerminatedBy); 226 } 227 if (ignoreLinesNumber !is null) { 228 children.add(ignoreLinesNumber); 229 } 230 return children; 231 } 232 233 234 public List!(SQLExpr) getColumns() { 235 return columns; 236 } 237 238 239 public void setColumns(List!(SQLExpr) columns) { 240 this.columns = columns; 241 } 242 243 244 public void setSetList(List!(SQLExpr) setList) { 245 this.setList = setList; 246 } 247 }