001package gudusoft.gsqlparser.nodes; 002 003import gudusoft.gsqlparser.ESqlClause; 004import gudusoft.gsqlparser.nodes.TParseTreeNode; 005import gudusoft.gsqlparser.nodes.TStatementListSqlNode; 006import gudusoft.gsqlparser.nodes.TObjectNameList; 007import gudusoft.gsqlparser.nodes.TParseTreeVisitor; 008import gudusoft.gsqlparser.TCustomSqlStatement; 009import gudusoft.gsqlparser.TStatementList; 010 011/** 012* An exception handler processes a raised exception. 013*/ 014public class TExceptionHandler extends TParseTreeNode { 015 private TStatementListSqlNode stmts = null; 016 private TObjectNameList exceptionNames = null; 017 018 /** 019 * A list of exception name which either a predefined exception (such as ZERO_DIVIDE), 020 * or a user-defined exception previously declared within the current scope. 021 * @return 022 */ 023 public TObjectNameList getExceptionNames() { 024 return exceptionNames; 025 } 026 027 public TStatementListSqlNode getStmts() { 028 return stmts; 029 } 030 031 public void init(Object arg1,Object arg2) 032 { 033 if (arg1 != null){ 034 exceptionNames = (TObjectNameList)arg1; 035 } 036 037 if (arg2 != null){ 038 stmts = (TStatementListSqlNode)arg2; 039 } 040 041 } 042 043 public void doParse(TCustomSqlStatement psql, ESqlClause plocation){ 044 if (stmts != null){ 045 stmts.doParse(psql,plocation); 046 for(int i=0;i<stmts.size();i++){ 047 this.getStatements().add(stmts.getStatementSqlNode(i).getStmt()); 048 } 049 } 050 } 051 052 /** 053 * These associated statements are executed when any exception in the {@link #getExceptionNames()} list is raised. . 054 * @return 055 */ 056 public TStatementList getStatements() { 057 if (statements == null){ 058 statements = new TStatementList(); 059 } 060 return statements; 061 } 062 063 private TStatementList statements = null; 064 065 public void accept(TParseTreeVisitor v){ 066 v.preVisit(this); 067 v.postVisit(this); 068 } 069 070 public void acceptChildren(TParseTreeVisitor v){ 071 v.preVisit(this); 072 if (this.getExceptionNames() != null){ 073 this.getExceptionNames().acceptChildren(v); 074 } 075 this.getStatements().acceptChildren(v); 076 v.postVisit(this); 077 } 078 079 public void setExceptionNames(TObjectNameList exceptionNames) { 080 this.exceptionNames = exceptionNames; 081 } 082 083 public void setStatements(TStatementList statements) { 084 this.statements = statements; 085 } 086}