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.SQLGrantStatement; 17 import hunt.sql.ast.statement.SQLObjectType; 18 19 20 import hunt.collection; 21 22 import hunt.sql.ast.SQLExpr; 23 import hunt.sql.ast.SQLObject; 24 import hunt.sql.ast.SQLStatementImpl; 25 import hunt.sql.visitor.SQLASTVisitor; 26 27 public class SQLGrantStatement : SQLStatementImpl { 28 29 protected List!SQLExpr privileges; 30 31 protected SQLObject on; 32 protected SQLExpr to; 33 34 public this(){ 35 privileges = new ArrayList!SQLExpr(); 36 } 37 38 public this(string dbType){ 39 privileges = new ArrayList!SQLExpr(); 40 super(dbType); 41 } 42 43 // mysql 44 protected SQLObjectType objectType; 45 private SQLExpr maxQueriesPerHour; 46 private SQLExpr maxUpdatesPerHour; 47 private SQLExpr maxConnectionsPerHour; 48 private SQLExpr maxUserConnections; 49 50 private bool adminOption; 51 52 private SQLExpr identifiedBy; 53 private string identifiedByPassword; 54 55 private bool withGrantOption; 56 57 58 override protected void accept0(SQLASTVisitor visitor) { 59 if (visitor.visit(this)) { 60 acceptChild!SQLExpr(visitor, this.privileges); 61 acceptChild(visitor, on); 62 acceptChild(visitor, to); 63 acceptChild(visitor, identifiedBy); 64 } 65 visitor.endVisit(this); 66 } 67 68 override 69 public List!SQLObject getChildren() { 70 List!SQLObject children = new ArrayList!SQLObject(); 71 children.addAll(cast(List!SQLObject)(privileges)); 72 if (on !is null) { 73 children.add(on); 74 } 75 if (to !is null) { 76 children.add(to); 77 } 78 if (identifiedBy !is null) { 79 children.add(identifiedBy); 80 } 81 return children; 82 } 83 84 public SQLObjectType getObjectType() { 85 return objectType; 86 } 87 88 public void setObjectType(SQLObjectType objectType) { 89 this.objectType = objectType; 90 } 91 92 public SQLObject getOn() { 93 return on; 94 } 95 96 public void setOn(SQLObject on) { 97 this.on = on; 98 on.setParent(this); 99 } 100 101 public SQLExpr getTo() { 102 return to; 103 } 104 105 public void setTo(SQLExpr to) { 106 this.to = to; 107 } 108 109 public List!SQLExpr getPrivileges() { 110 return privileges; 111 } 112 113 public SQLExpr getMaxQueriesPerHour() { 114 return maxQueriesPerHour; 115 } 116 117 public void setMaxQueriesPerHour(SQLExpr maxQueriesPerHour) { 118 this.maxQueriesPerHour = maxQueriesPerHour; 119 } 120 121 public SQLExpr getMaxUpdatesPerHour() { 122 return maxUpdatesPerHour; 123 } 124 125 public void setMaxUpdatesPerHour(SQLExpr maxUpdatesPerHour) { 126 this.maxUpdatesPerHour = maxUpdatesPerHour; 127 } 128 129 public SQLExpr getMaxConnectionsPerHour() { 130 return maxConnectionsPerHour; 131 } 132 133 public void setMaxConnectionsPerHour(SQLExpr maxConnectionsPerHour) { 134 this.maxConnectionsPerHour = maxConnectionsPerHour; 135 } 136 137 public SQLExpr getMaxUserConnections() { 138 return maxUserConnections; 139 } 140 141 public void setMaxUserConnections(SQLExpr maxUserConnections) { 142 this.maxUserConnections = maxUserConnections; 143 } 144 145 public bool isAdminOption() { 146 return adminOption; 147 } 148 149 public void setAdminOption(bool adminOption) { 150 this.adminOption = adminOption; 151 } 152 153 public SQLExpr getIdentifiedBy() { 154 return identifiedBy; 155 } 156 157 public void setIdentifiedBy(SQLExpr identifiedBy) { 158 this.identifiedBy = identifiedBy; 159 } 160 161 public string getIdentifiedByPassword() { 162 return identifiedByPassword; 163 } 164 165 public void setIdentifiedByPassword(string identifiedByPassword) { 166 this.identifiedByPassword = identifiedByPassword; 167 } 168 169 public bool getWithGrantOption() { 170 return withGrantOption; 171 } 172 173 public void setWithGrantOption(bool withGrantOption) { 174 this.withGrantOption = withGrantOption; 175 } 176 }