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.dialect.postgresql.ast.stmt.PGConnectToStatement; 17 18 import hunt.sql.SQLUtils; 19 import hunt.sql.ast.SQLName; 20 import hunt.sql.ast.SQLStatementImpl; 21 import hunt.sql.dialect.postgresql.visitor.PGASTVisitor; 22 import hunt.sql.visitor.SQLASTOutputVisitor; 23 import hunt.sql.visitor.SQLASTVisitor; 24 import hunt.sql.util.DBType; 25 import hunt.sql.dialect.postgresql.ast.stmt.PGSQLStatement; 26 import hunt.collection; 27 import hunt.util.StringBuilder; 28 29 public class PGConnectToStatement : SQLStatementImpl , PGSQLStatement { 30 private SQLName target; 31 32 public this() { 33 super(DBType.POSTGRESQL.name); 34 } 35 36 override protected void accept0(SQLASTVisitor visitor) { 37 this.accept0(cast(PGASTVisitor) visitor); 38 } 39 40 override public void output(StringBuilder buf) { 41 SQLASTOutputVisitor visitor = SQLUtils.createOutputVisitor(buf, dbType); 42 this.accept(visitor); 43 } 44 45 override 46 public void accept0(PGASTVisitor v) { 47 if (v.visit(this)) { 48 acceptChild(v, target); 49 } 50 v.endVisit(this); 51 } 52 53 public SQLName getTarget() { 54 return target; 55 } 56 57 public void setTarget(SQLName x) { 58 if (x !is null) { 59 x.setParent(this); 60 } 61 this.target = x; 62 } 63 }