1 8 package org.lsmp.djep.xjep; 9 import org.nfunk.jep.*; 11 12 26 abstract public class ErrorCatchingVisitor extends DoNothingVisitor 27 { 28 29 private Exception error=null; 30 31 32 public Object acceptCatchingErrors(Node node,Object data) 33 { 34 Object res=null; 35 clearErrors(); 36 try 37 { 38 res = node.jjtAccept(this,data); 39 } 40 catch (ParseException e) { addError(e); } 41 return res; 42 } 43 44 public void clearErrors() { error = null; } 45 46 47 public boolean hasErrors() { return error != null; } 48 49 50 public void addError(Exception e) {error = e; } 51 52 53 public String getErrorsMessage() { 54 if(error==null) return null; 55 else return error.getMessage(); 56 } 57 58 public Exception getError() { return error; } 59 } 60 | Popular Tags |