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.SQLCallStatement;
17 
18 import hunt.collection;
19 
20 import hunt.sql.ast.SQLExpr;
21 import hunt.sql.ast.SQLName;
22 import hunt.sql.ast.SQLObject;
23 import hunt.sql.ast.SQLStatementImpl;
24 import hunt.sql.ast.expr.SQLVariantRefExpr;
25 import hunt.sql.visitor.SQLASTVisitor;
26 
27 public class SQLCallStatement : SQLStatementImpl {
28 
29     private bool             brace      = false;
30 
31     private SQLVariantRefExpr   outParameter;
32 
33     private SQLName             procedureName;
34 
35     private  List!SQLExpr parameters;
36     
37     public this() {
38         parameters = new ArrayList!SQLExpr();
39     }
40     
41     public this(string dbType) {
42         super (dbType);
43     }
44 
45     public SQLVariantRefExpr getOutParameter() {
46         return outParameter;
47     }
48 
49     public void setOutParameter(SQLVariantRefExpr outParameter) {
50         this.outParameter = outParameter;
51     }
52 
53     public SQLName getProcedureName() {
54         return procedureName;
55     }
56 
57     public void setProcedureName(SQLName procedureName) {
58         this.procedureName = procedureName;
59     }
60 
61     public List!SQLExpr getParameters() {
62         return parameters;
63     }
64 
65     public bool isBrace() {
66         return brace;
67     }
68 
69     public void setBrace(bool brace) {
70         this.brace = brace;
71     }
72 
73     override  protected void accept0(SQLASTVisitor visitor) {
74         if (visitor.visit(this)) {
75             acceptChild(visitor, this.outParameter);
76             acceptChild(visitor, this.procedureName);
77             acceptChild!SQLExpr(visitor, this.parameters);
78         }
79         visitor.endVisit(this);
80     }
81 
82     override
83     public List!SQLObject getChildren() {
84         List!SQLObject children = new ArrayList!SQLObject();
85         children.add(outParameter);
86         children.add(procedureName);
87         children.addAll(cast(List!SQLObject)(parameters));
88         return null;
89     }
90 }