001package gudusoft.gsqlparser.stmt.db2; 002 003import gudusoft.gsqlparser.*; 004import gudusoft.gsqlparser.nodes.TIfSqlNode; 005import gudusoft.gsqlparser.nodes.TExpression; 006import gudusoft.gsqlparser.nodes.TElseIfSqlNodeList; 007import gudusoft.gsqlparser.nodes.TParseTreeVisitor; 008 009/** 010 * @deprecated since v2.8.8.9, use {@link gudusoft.gsqlparser.stmt.TIfStmt} instead 011 */ 012public class TDb2IfStmt extends TCustomDb2Stmt { 013 public TDb2IfStmt (EDbVendor dbvendor){ 014 super(dbvendor); 015 sqlstatementtype = ESqlStatementType.sstdb2ifstmt ; 016 } 017 018 void buildsql() { 019 } 020 021 void clear() { 022 } 023 024 String getasprettytext() { 025 return ""; 026 } 027 028 void iterate(TVisitorAbs pvisitor) { 029 } 030 031 public int doParseStatement(TCustomSqlStatement psql) { 032 if (rootNode == null) return -1; 033 TIfSqlNode ifSqlNode = (TIfSqlNode)rootNode; 034 super.doParseStatement(psql); 035 this.condition = ifSqlNode.getCondition(); 036 condition.doParse(this,ESqlClause.unknown); 037 if (ifSqlNode.getThenStmts() != null){ 038 ifSqlNode.getThenStmts().doParse(this,ESqlClause.unknown); 039 for(int i=0;i<ifSqlNode.getThenStmts().size();i++){ 040 this.getThenStmts().add(ifSqlNode.getThenStmts().getStatementSqlNode(i).getStmt()); 041 } 042 } 043 044 if (ifSqlNode.getElseIfList() != null){ 045 ifSqlNode.getElseIfList().doParse(this,ESqlClause.unknown); 046 this.elseIfList = ifSqlNode.getElseIfList(); 047 } 048 049 if (ifSqlNode.getElseStmts() != null){ 050 ifSqlNode.getElseStmts().doParse(this,ESqlClause.unknown); 051 for(int i=0;i<ifSqlNode.getElseStmts().size();i++){ 052 this.getElseStmts().add(ifSqlNode.getElseStmts().getStatementSqlNode(i).getStmt()); 053 } 054 } 055 056 return 0; 057 } 058 059 private TExpression condition = null; 060 061 public TExpression getCondition() { 062 return condition; 063 } 064 065 private TStatementList thenStmts = null; 066 private TStatementList elseStmts = null; 067 068 public TStatementList getElseStmts() { 069 if (this.elseStmts == null){ 070 this.elseStmts = new TStatementList(); 071 } 072 return elseStmts; 073 } 074 075 public TStatementList getThenStmts() { 076 if (this.thenStmts == null){ 077 this.thenStmts = new TStatementList(); 078 } 079 return thenStmts; 080 } 081 082 private TElseIfSqlNodeList elseIfList = null; 083 084 public TElseIfSqlNodeList getElseIfList() { 085 return elseIfList; 086 } 087 088// public void accept(TParseTreeVisitor v){ 089// v.preVisit(this); 090// v.postVisit(this); 091// } 092// 093// public void acceptChildren(TParseTreeVisitor v){ 094// v.preVisit(this); 095// condition.accept(v); 096// if (thenStmts != null) thenStmts.acceptChildren(v); 097// if (elseIfList != null) elseIfList.acceptChildren(v); 098// if (elseStmts != null) elseStmts.acceptChildren(v); 099// v.postVisit(this); 100// } 101 102 public void setCondition(TExpression condition) { 103 this.condition = condition; 104 } 105 106 public void setThenStmts(TStatementList thenStmts) { 107 this.thenStmts = thenStmts; 108 } 109 110 public void setElseStmts(TStatementList elseStmts) { 111 this.elseStmts = elseStmts; 112 } 113}