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.expr.MySqlOutFileExpr;
17 
18 import hunt.sql.ast.SQLExpr;
19 import hunt.sql.ast.expr.SQLLiteralExpr;
20 import hunt.sql.dialect.mysql.ast.MySqlObjectImpl;
21 import hunt.sql.dialect.mysql.visitor.MySqlASTVisitor;
22 import hunt.sql.ast.SQLDataType;
23 import hunt.sql.ast.SQLObject;
24 
25 import hunt.collection;
26 
27 public class MySqlOutFileExpr : MySqlObjectImpl , SQLExpr {
28 
29     alias accept0 = MySqlObjectImpl.accept0;
30     alias computeDataType = MySqlObjectImpl.computeDataType;
31 
32     private SQLExpr        file;
33     private string         charset;
34 
35     private SQLExpr        columnsTerminatedBy;
36     private bool        columnsEnclosedOptionally = false;
37     private SQLLiteralExpr columnsEnclosedBy;
38     private SQLLiteralExpr columnsEscaped;
39 
40     private SQLLiteralExpr linesStartingBy;
41     private SQLLiteralExpr linesTerminatedBy;
42 
43     private SQLExpr        ignoreLinesNumber;
44 
45     public this(){
46     }
47 
48     public this(SQLExpr file){
49         this.file = file;
50     }
51 
52     override public SQLDataType computeDataType()
53     {
54         return super.computeDataType();
55     }
56 
57     override
58     public void accept0(MySqlASTVisitor visitor) {
59         if (visitor.visit(this)) {
60             acceptChild(visitor, file);
61         }
62         visitor.endVisit(this);
63     }
64 
65     override
66     public List!SQLObject getChildren() {
67         return Collections.singletonList!SQLObject(file);
68     }
69 
70     public SQLExpr getFile() {
71         return file;
72     }
73 
74     public void setFile(SQLExpr file) {
75         this.file = file;
76     }
77 
78     public string getCharset() {
79         return charset;
80     }
81 
82     public void setCharset(string charset) {
83         this.charset = charset;
84     }
85 
86     public SQLExpr getColumnsTerminatedBy() {
87         return columnsTerminatedBy;
88     }
89 
90     public void setColumnsTerminatedBy(SQLExpr columnsTerminatedBy) {
91         this.columnsTerminatedBy = columnsTerminatedBy;
92     }
93 
94     public bool isColumnsEnclosedOptionally() {
95         return columnsEnclosedOptionally;
96     }
97 
98     public void setColumnsEnclosedOptionally(bool columnsEnclosedOptionally) {
99         this.columnsEnclosedOptionally = columnsEnclosedOptionally;
100     }
101 
102     public SQLLiteralExpr getColumnsEnclosedBy() {
103         return columnsEnclosedBy;
104     }
105 
106     public void setColumnsEnclosedBy(SQLLiteralExpr columnsEnclosedBy) {
107         this.columnsEnclosedBy = columnsEnclosedBy;
108     }
109 
110     public SQLLiteralExpr getColumnsEscaped() {
111         return columnsEscaped;
112     }
113 
114     public void setColumnsEscaped(SQLLiteralExpr columnsEscaped) {
115         this.columnsEscaped = columnsEscaped;
116     }
117 
118     public SQLLiteralExpr getLinesStartingBy() {
119         return linesStartingBy;
120     }
121 
122     public void setLinesStartingBy(SQLLiteralExpr linesStartingBy) {
123         this.linesStartingBy = linesStartingBy;
124     }
125 
126     public SQLLiteralExpr getLinesTerminatedBy() {
127         return linesTerminatedBy;
128     }
129 
130     public void setLinesTerminatedBy(SQLLiteralExpr linesTerminatedBy) {
131         this.linesTerminatedBy = linesTerminatedBy;
132     }
133 
134     public SQLExpr getIgnoreLinesNumber() {
135         return ignoreLinesNumber;
136     }
137 
138     public void setIgnoreLinesNumber(SQLExpr ignoreLinesNumber) {
139         this.ignoreLinesNumber = ignoreLinesNumber;
140     }
141 
142     override public SQLExpr clone() {
143         throw new Exception("unsuported operation");
144     }
145 
146 }