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