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.MySqlShowKeysStatement;
17 
18 import hunt.sql.ast.SQLName;
19 import hunt.sql.ast.expr.SQLIdentifierExpr;
20 import hunt.sql.ast.expr.SQLPropertyExpr;
21 import hunt.sql.dialect.mysql.visitor.MySqlASTVisitor;
22 import hunt.sql.dialect.mysql.ast.statement.MySqlStatementImpl;
23 import hunt.sql.dialect.mysql.ast.statement.MySqlShowStatement;
24 
25 public class MySqlShowKeysStatement : MySqlStatementImpl , MySqlShowStatement {
26     alias accept0 = MySqlStatementImpl.accept0;
27     private SQLName table;
28     private SQLName database;
29 
30     public SQLName getTable() {
31         return table;
32     }
33 
34     public void setTable(SQLName table) {
35         if (cast(SQLPropertyExpr)(table) !is null) {
36             SQLPropertyExpr propExpr = cast(SQLPropertyExpr) table;
37             this.setDatabase(cast(SQLName) propExpr.getOwner());
38             this.table = new SQLIdentifierExpr(propExpr.getName());
39             return;
40         }
41         this.table = table;
42     }
43 
44     public SQLName getDatabase() {
45         return database;
46     }
47 
48     public void setDatabase(SQLName database) {
49         this.database = database;
50     }
51 
52     override public void accept0(MySqlASTVisitor visitor) {
53         if (visitor.visit(this)) {
54             acceptChild(visitor, table);
55             acceptChild(visitor, database);
56         }
57         visitor.endVisit(this);
58     }
59 }