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.SQLDumpStatement;
17 
18 import hunt.sql.ast.SQLExpr;
19 import hunt.sql.ast.SQLStatementImpl;
20 import hunt.sql.visitor.SQLASTVisitor;
21 import hunt.sql.ast.statement.SQLExprTableSource;
22 import hunt.sql.ast.statement.SQLSelect;
23 
24 public class SQLDumpStatement : SQLStatementImpl {
25     private bool overwrite;
26     private SQLExprTableSource into;
27 
28     private SQLSelect select;
29 
30     public this() {
31 
32     }
33 
34     public SQLSelect getSelect() {
35         return select;
36     }
37 
38     public void setSelect(SQLSelect x) {
39         if (x !is null) {
40             x.setParent(this);
41         }
42 
43         this.select = x;
44     }
45 
46     public SQLExprTableSource getInto() {
47         return into;
48     }
49 
50     public void setInto(SQLExpr x) {
51         if (x is null) {
52             return;
53         }
54 
55         setInto(new SQLExprTableSource(x));
56     }
57 
58     public void setInto(SQLExprTableSource x) {
59         if (x !is null) {
60             x.setParent(this);
61         }
62 
63         this.into = x;
64     }
65 
66     public bool isOverwrite() {
67         return overwrite;
68     }
69 
70     public void setOverwrite(bool overwrite) {
71         this.overwrite = overwrite;
72     }
73 
74     
75     override  protected void accept0(SQLASTVisitor visitor) {
76         if (visitor.visit(this)) {
77             if (into !is null) {
78                 into.accept(visitor);
79             }
80 
81             if (select !is null) {
82                 select.accept(visitor);
83             }
84         }
85         visitor.endVisit(this);
86     }
87 }