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.SQLValuesTableSource; 17 18 import hunt.sql.ast.SQLHint; 19 import hunt.sql.ast.SQLName; 20 import hunt.sql.ast.expr.SQLListExpr; 21 import hunt.sql.visitor.SQLASTVisitor; 22 import hunt.sql.ast.statement.SQLTableSourceImpl; 23 import hunt.sql.ast.SQLObject; 24 25 26 import hunt.collection; 27 28 /** 29 * Created by wenshao on 23/02/2017. 30 */ 31 public class SQLValuesTableSource : SQLTableSourceImpl { 32 private List!SQLListExpr values; 33 private List!SQLName columns; 34 35 this() 36 { 37 values = new ArrayList!SQLListExpr(); 38 columns = new ArrayList!SQLName(); 39 } 40 41 public List!SQLListExpr getValues() { 42 return values; 43 } 44 45 public List!SQLName getColumns() { 46 return columns; 47 } 48 49 override 50 public void accept0(SQLASTVisitor visitor) { 51 if (visitor.visit(this)) { 52 acceptChild!SQLListExpr(visitor, values); 53 acceptChild!SQLName(visitor, columns); 54 } 55 visitor.endVisit(this); 56 } 57 58 override 59 public SQLValuesTableSource clone() { 60 61 SQLValuesTableSource x = new SQLValuesTableSource(); 62 63 x.setAlias(this._alias); 64 65 foreach (SQLListExpr e ; this.values) { 66 SQLListExpr e2 = e.clone(); 67 e2.setParent(x); 68 x.getValues().add(e2); 69 } 70 71 foreach (SQLName e ; this.columns) { 72 SQLName e2 = e.clone(); 73 e2.setParent(x); 74 x.getColumns().add(e2); 75 } 76 77 if (this.flashback !is null) { 78 x.setFlashback(this.flashback.clone()); 79 } 80 81 if (this.hints !is null) { 82 foreach (SQLHint e ; this.hints) { 83 SQLHint e2 = e.clone(); 84 e2.setParent(x); 85 x.getHints().add(e2); 86 } 87 } 88 89 return x; 90 } 91 }