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.SQLCommentStatement; 17 18 import hunt.sql.ast; 19 import hunt.sql.visitor.SQLASTVisitor; 20 import hunt.sql.ast.statement.SQLExprTableSource; 21 22 import hunt.collection; 23 24 public class SQLCommentStatement : SQLStatementImpl { 25 26 public static struct Type { 27 enum Type TABLE = Type("TABLE"); 28 enum Type COLUMN = Type("COLUMN"); 29 30 private string _name; 31 32 this(string name) 33 { 34 _name = name; 35 } 36 37 @property string name() 38 { 39 return _name; 40 } 41 42 bool opEquals(const Type h) nothrow { 43 return _name == h._name ; 44 } 45 46 bool opEquals(ref const Type h) nothrow { 47 return _name == h._name ; 48 } 49 } 50 51 private SQLExprTableSource on; 52 private Type type; 53 private SQLExpr comment; 54 55 public SQLExpr getComment() { 56 return comment; 57 } 58 59 public void setComment(SQLExpr comment) { 60 this.comment = comment; 61 } 62 63 public Type getType() { 64 return type; 65 } 66 67 public void setType(Type type) { 68 this.type = type; 69 } 70 71 public SQLExprTableSource getOn() { 72 return on; 73 } 74 75 public void setOn(SQLExprTableSource on) { 76 if (on !is null) { 77 on.setParent(this); 78 } 79 this.on = on; 80 } 81 82 public void setOn(SQLName on) { 83 this.setOn(new SQLExprTableSource(on)); 84 } 85 86 87 override protected void accept0(SQLASTVisitor visitor) { 88 if (visitor.visit(this)) { 89 acceptChild(visitor, on); 90 acceptChild(visitor, comment); 91 } 92 visitor.endVisit(this); 93 } 94 95 override 96 public List!SQLObject getChildren() { 97 List!SQLObject children = new ArrayList!SQLObject(); 98 if (on !is null) { 99 children.add(on); 100 } 101 if (comment !is null) { 102 children.add(comment); 103 } 104 return children; 105 } 106 }