001package gudusoft.gsqlparser.stmt.mssql; 002 003import gudusoft.gsqlparser.*; 004import gudusoft.gsqlparser.nodes.TDropDbObjectSqlNode; 005import gudusoft.gsqlparser.nodes.TObjectName; 006import gudusoft.gsqlparser.nodes.TObjectNameList; 007import gudusoft.gsqlparser.nodes.TParseTreeVisitor; 008 009public class TMssqlDropDbObject extends TCustomSqlStatement { 010 public TMssqlDropDbObject (EDbVendor dbvendor){ 011 super(dbvendor); 012 sqlstatementtype = ESqlStatementType.sstmssqldropdbobject ; 013 } 014 015 void buildsql() { 016 } 017 018 void clear() { 019 } 020 021 String getasprettytext() { 022 return ""; 023 } 024 025 void iterate(TVisitorAbs pvisitor) { 026 } 027 028 private TObjectNameList objectNameList = null; 029 030 public TObjectNameList getObjectNameList() { 031 return objectNameList; 032 } 033 034 private EDbObjectType dbObjectType; 035 036 037 public EDbObjectType getDbObjectType() { 038 039 return dbObjectType; 040 } 041 042 private boolean ifExists = false; 043 044 /** 045 * True when the DROP statement carried an {@code IF EXISTS} clause, e.g. 046 * {@code DROP PROCEDURE IF EXISTS p1} in SQL Anywhere / SAP IQ. 047 */ 048 public boolean isIfExists() { 049 return ifExists; 050 } 051 052 public void setIfExists(boolean ifExists) { 053 this.ifExists = ifExists; 054 } 055 056 public int doParseStatement(TCustomSqlStatement psql) { 057 if (rootNode == null) return -1; 058 super.doParseStatement(psql); 059 if (rootNode instanceof TDropDbObjectSqlNode){ 060 // don't parse sql when root node is type of TMssqlStmtStubSqlNode 061 TDropDbObjectSqlNode dropDbObjectNode = (TDropDbObjectSqlNode)rootNode; 062 this.objectNameList = dropDbObjectNode.getObjectNameList(); 063 if (objectNameList != null){ 064 for(int i=0;i<objectNameList.size();i++){ 065 objectNameList.getObjectName(0).setObjectType(TObjectName.ttobjTable); 066 } 067 } 068 this.dbObjectType = dropDbObjectNode.getDbObjectType(); 069 this.ifExists = dropDbObjectNode.isIfExists(); 070 } 071 return 0; 072 } 073 074 public void accept(TParseTreeVisitor v){ 075 v.preVisit(this); 076 v.postVisit(this); 077 } 078 079 public void acceptChildren(TParseTreeVisitor v){ 080 v.preVisit(this); 081 v.postVisit(this); 082 } 083 084 public void setObjectNameList(TObjectNameList objectNameList) { 085 this.objectNameList = objectNameList; 086 } 087 088 public void setDbObjectType(EDbObjectType dbObjectType) { 089 this.dbObjectType = dbObjectType; 090 } 091}