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.SQLCreateProcedureStatement; 17 18 import hunt.collection; 19 20 import hunt.sql.ast.SQLName; 21 import hunt.sql.ast.SQLParameter; 22 import hunt.sql.ast.SQLStatement; 23 import hunt.sql.ast.SQLStatementImpl; 24 import hunt.sql.visitor.SQLASTVisitor; 25 import hunt.sql.ast.statement.SQLCreateStatement; 26 import hunt.sql.ast.SQLObject; 27 28 29 public class SQLCreateProcedureStatement : SQLStatementImpl , SQLCreateStatement { 30 31 private SQLName definer; 32 33 private bool create = true; 34 private bool orReplace; 35 private SQLName name; 36 private SQLStatement block; 37 private List!SQLParameter parameters; 38 39 // for oracle 40 private string javaCallSpec; 41 42 private SQLName authid; 43 44 // for mysql 45 private bool deterministic; 46 private bool containsSql; 47 private bool noSql; 48 private bool readSqlData; 49 private bool modifiesSqlData; 50 51 private string wrappedSource; 52 53 this() 54 { 55 parameters = new ArrayList!SQLParameter(); 56 } 57 58 override 59 public void accept0(SQLASTVisitor visitor) { 60 if (visitor.visit(this)) { 61 acceptChild(visitor, definer); 62 acceptChild(visitor, name); 63 acceptChild!SQLParameter(visitor, parameters); 64 acceptChild(visitor, block); 65 } 66 visitor.endVisit(this); 67 } 68 69 public List!SQLParameter getParameters() { 70 return parameters; 71 } 72 73 public void setParameters(List!SQLParameter parameters) { 74 this.parameters = parameters; 75 } 76 77 public SQLName getName() { 78 return name; 79 } 80 81 public void setName(SQLName name) { 82 this.name = name; 83 } 84 85 public SQLStatement getBlock() { 86 return block; 87 } 88 89 public void setBlock(SQLStatement block) { 90 if (block !is null) { 91 block.setParent(this); 92 } 93 this.block = block; 94 } 95 96 public SQLName getAuthid() { 97 return authid; 98 } 99 100 public void setAuthid(SQLName authid) { 101 if (authid !is null) { 102 authid.setParent(this); 103 } 104 this.authid = authid; 105 } 106 107 public bool isOrReplace() { 108 return orReplace; 109 } 110 111 public void setOrReplace(bool orReplace) { 112 this.orReplace = orReplace; 113 } 114 115 public SQLName getDefiner() { 116 return definer; 117 } 118 119 public void setDefiner(SQLName definer) { 120 this.definer = definer; 121 } 122 123 public bool isCreate() { 124 return create; 125 } 126 127 public void setCreate(bool create) { 128 this.create = create; 129 } 130 131 public string getJavaCallSpec() { 132 return javaCallSpec; 133 } 134 135 public void setJavaCallSpec(string javaCallSpec) { 136 this.javaCallSpec = javaCallSpec; 137 } 138 139 public bool isDeterministic() { 140 return deterministic; 141 } 142 143 public void setDeterministic(bool deterministic) { 144 this.deterministic = deterministic; 145 } 146 147 public bool isContainsSql() { 148 return containsSql; 149 } 150 151 public void setContainsSql(bool containsSql) { 152 this.containsSql = containsSql; 153 } 154 155 public bool isNoSql() { 156 return noSql; 157 } 158 159 public void setNoSql(bool noSql) { 160 this.noSql = noSql; 161 } 162 163 public bool isReadSqlData() { 164 return readSqlData; 165 } 166 167 public void setReadSqlData(bool readSqlData) { 168 this.readSqlData = readSqlData; 169 } 170 171 public bool isModifiesSqlData() { 172 return modifiesSqlData; 173 } 174 175 public void setModifiesSqlData(bool modifiesSqlData) { 176 this.modifiesSqlData = modifiesSqlData; 177 } 178 179 public SQLParameter findParameter(long hash) { 180 foreach (SQLParameter param ; this.parameters) { 181 if (param.getName().nameHashCode64() == hash) { 182 return param; 183 } 184 } 185 186 return null; 187 } 188 189 public string getWrappedSource() { 190 return wrappedSource; 191 } 192 193 public void setWrappedSource(string wrappedSource) { 194 this.wrappedSource = wrappedSource; 195 } 196 }