001package gudusoft.gsqlparser.stmt; 002 003import gudusoft.gsqlparser.EDbVendor; 004import gudusoft.gsqlparser.ESqlStatementType; 005import gudusoft.gsqlparser.TVisitorAbs; 006import gudusoft.gsqlparser.TCustomSqlStatement; 007import gudusoft.gsqlparser.nodes.TDropViewSqlNode; 008import gudusoft.gsqlparser.nodes.TObjectName; 009import gudusoft.gsqlparser.nodes.TParseTreeVisitor; 010import gudusoft.gsqlparser.nodes.TObjectNameList; 011 012/** 013 * remove a view or an object view from the database. 014 */ 015public class TDropViewSqlStatement extends TCustomSqlStatement { 016 public TDropViewSqlStatement(EDbVendor dbvendor) { 017 super(dbvendor); 018 sqlstatementtype = ESqlStatementType.sstdropview; 019 } 020 021 private boolean ifExists; 022 023 public void setIfExists(boolean ifExists) { 024 this.ifExists = ifExists; 025 } 026 027 public boolean isIfExists() { 028 return ifExists; 029 } 030 031 void buildsql() { 032 } 033 034 void clear() { 035 } 036 037 String getasprettytext() { 038 return ""; 039 } 040 041 void iterate(TVisitorAbs pvisitor) { 042 } 043 044 public int doParseStatement(TCustomSqlStatement psql) { 045 if (rootNode == null) return -1; 046 TDropViewSqlNode dropViewNode = (TDropViewSqlNode)rootNode; 047 super.doParseStatement(psql); 048 049 this.viewName = dropViewNode.getViewName(); 050 this.viewNameList = dropViewNode.getViewNameList(); 051 this.ifExists = dropViewNode.isIfExists(); 052 if (this.viewNameList != null){ 053 this.viewName = this.viewNameList.getObjectName(0); 054 } 055 return 0; 056 } 057 058 /** 059 * 060 * @return the name of the view to be dropped. 061 */ 062 public TObjectName getViewName() { 063 return viewName; 064 } 065 066 private TObjectName viewName = null; 067 068 069 070 private TObjectNameList viewNameList = null; 071 072 /** 073 * 074 * @return list of views to be drop, used in sql server. 075 */ 076 public TObjectNameList getViewNameList() { 077 return viewNameList; 078 } 079 080 public void accept(TParseTreeVisitor v){ 081 v.preVisit(this); 082 v.postVisit(this); 083 } 084 085 public void acceptChildren(TParseTreeVisitor v){ 086 v.preVisit(this); 087 v.postVisit(this); 088 } 089 090 public void setViewName(TObjectName viewName) { 091 this.viewName = viewName; 092 } 093 094 public void setViewNameList(TObjectNameList viewNameList) { 095 this.viewNameList = viewNameList; 096 } 097}