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.MySqlShowColumnsStatement; 17 18 import hunt.sql.ast.SQLExpr; 19 import hunt.sql.ast.SQLName; 20 import hunt.sql.ast.SQLObject; 21 import hunt.sql.ast.expr.SQLIdentifierExpr; 22 import hunt.sql.ast.expr.SQLPropertyExpr; 23 import hunt.sql.dialect.mysql.visitor.MySqlASTVisitor; 24 import hunt.sql.dialect.mysql.ast.statement.MySqlShowStatement; 25 26 import hunt.sql.dialect.mysql.ast.statement.MySqlStatementImpl; 27 28 import hunt.collection; 29 30 public class MySqlShowColumnsStatement : MySqlStatementImpl , MySqlShowStatement { 31 32 alias accept0 = MySqlStatementImpl.accept0; 33 34 private bool full; 35 36 private SQLName table; 37 private SQLName database; 38 private SQLExpr like; 39 private SQLExpr where; 40 41 public bool isFull() { 42 return full; 43 } 44 45 public void setFull(bool full) { 46 this.full = full; 47 } 48 49 public SQLName getTable() { 50 return table; 51 } 52 53 public void setTable(SQLName table) { 54 if (cast(SQLPropertyExpr)(table) !is null) { 55 SQLPropertyExpr propExpr = cast(SQLPropertyExpr) table; 56 this.setDatabase(cast(SQLName) propExpr.getOwner()); 57 this.table = new SQLIdentifierExpr(propExpr.getName()); 58 return; 59 } 60 this.table = table; 61 } 62 63 public SQLName getDatabase() { 64 return database; 65 } 66 67 public void setDatabase(SQLName database) { 68 this.database = database; 69 } 70 71 public SQLExpr getLike() { 72 return like; 73 } 74 75 public void setLike(SQLExpr like) { 76 this.like = like; 77 } 78 79 public SQLExpr getWhere() { 80 return where; 81 } 82 83 public void setWhere(SQLExpr where) { 84 this.where = where; 85 } 86 87 override public void accept0(MySqlASTVisitor visitor) { 88 if (visitor.visit(this)) { 89 acceptChild(visitor, table); 90 acceptChild(visitor, database); 91 acceptChild(visitor, like); 92 acceptChild(visitor, where); 93 } 94 visitor.endVisit(this); 95 } 96 97 override public List!(SQLObject) getChildren() { 98 List!(SQLObject) children = new ArrayList!(SQLObject)(); 99 if (table !is null) { 100 children.add(table); 101 } 102 if (database !is null) { 103 children.add(database); 104 } 105 if (like !is null) { 106 children.add(like); 107 } 108 if (where !is null) { 109 children.add(where); 110 } 111 return children; 112 } 113 }