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.SQLOpenStatement;
17 
18 import hunt.sql.ast.SQLExpr;
19 import hunt.sql.ast.SQLName;
20 import hunt.sql.ast.SQLStatementImpl;
21 import hunt.sql.ast.expr.SQLIdentifierExpr;
22 import hunt.sql.visitor.SQLASTVisitor;
23 import hunt.sql.ast.SQLObject;
24 
25 
26 import hunt.collection;
27 
28 
29 public class SQLOpenStatement : SQLStatementImpl{
30 	
31 	//cursor name
32 	private SQLName cursorName;
33 
34 	private  List!SQLName columns;
35 
36 	private SQLExpr forExpr;
37 
38 	public this() {
39 		columns = new ArrayList!SQLName();
40 	}
41 	
42 	public SQLName getCursorName() {
43 		return cursorName;
44 	}
45 	
46 	public void setCursorName(string cursorName) {
47 		setCursorName(new SQLIdentifierExpr(cursorName));
48 	}
49 
50 	public void setCursorName(SQLName cursorName) {
51 		if (cursorName !is null) {
52 			cursorName.setParent(this);
53 		}
54 		this.cursorName = cursorName;
55 	}
56 
57 	
58 	override  protected void accept0(SQLASTVisitor visitor) {
59 		if (visitor.visit(this)) {
60 			acceptChild(visitor, cursorName);
61 			acceptChild(visitor, forExpr);
62 			acceptChild!SQLName(visitor, columns);
63 		}
64 	    visitor.endVisit(this);
65 	}
66 
67 	public SQLExpr getFor() {
68 		return forExpr;
69 	}
70 
71 	public void setFor(SQLExpr forExpr) {
72 		if (forExpr !is null) {
73 			forExpr.setParent(this);
74 		}
75 		this.forExpr = forExpr;
76 	}
77 
78 	public List!SQLName getColumns() {
79 		return columns;
80 	}
81 }