package refactoring.struts; import java.util.List; import org.apache.struts.config.ExceptionConfig; import refactoring.struts.beans.ExceptionHandlingBean; import refactoring.struts.beans.MappingAnnotationBean; public class ExceptionsCreator { public static void createException(final ExceptionConfig exceptionConfig, MappingAnnotationBean mappingBean) { final String exceptionHandler = exceptionConfig.getHandler(); final String messageKey = exceptionConfig.getKey(); final String exceptionTypeName = exceptionConfig.getType(); final String path = exceptionConfig.getPath(); final String scope = exceptionConfig.getScope(); ExceptionHandlingBean exceptionHandling = new ExceptionHandlingBean(); exceptionHandling.setHandler(exceptionHandler); exceptionHandling.setKey(messageKey); exceptionHandling.setType(exceptionTypeName); exceptionHandling.setPath(path); exceptionHandling.setScope(scope); mappingBean.addExceptionHandler(exceptionHandling); } public static String createExceptionsAnnotation(final List exceptionsList) { StringBuilder sourceCode = new StringBuilder(); sourceCode.append("@Exceptions( {"); sourceCode.append("\n"); int i; for (i = 0; i < (exceptionsList.size() - 1); i++) { sourceCode.append(exceptionsList.get(i)); sourceCode.append("," + "\n"); } sourceCode.append(exceptionsList.get(i)); sourceCode.append("\n" + "} )"); return sourceCode.toString(); } }