package refactoring.struts; import java.util.List; import org.apache.struts.config.ForwardConfig; import refactoring.struts.beans.ForwardAnnotationBean; import refactoring.struts.beans.MappingAnnotationBean; public class ForwardCreator { public static String createForward(ForwardConfig forwardConfig, MappingAnnotationBean mappingBean) { StringBuilder sourceCode = new StringBuilder(); sourceCode.append("@Forward( "); String name = forwardConfig.getName(); String path = forwardConfig.getPath(); Boolean redirect = forwardConfig.getRedirect(); Boolean contextRelative = forwardConfig.getContextRelative(); sourceCode.append("name = " + name); sourceCode.append(", path = " + path); if (redirect) { sourceCode.append(", redirect = " + redirect); } if (contextRelative) { sourceCode.append(", contextRelative = " + contextRelative); } sourceCode.append(")"); ForwardAnnotationBean forwardBean = new ForwardAnnotationBean(); forwardBean.setContextRelative(contextRelative); forwardBean.setName(name); forwardBean.setPath(path); forwardBean.setRedirect(redirect); // forwardBean.setTileProperties(tileProperties); // forwardBean.setUseTile(useTile); mappingBean.addForward(forwardBean); return sourceCode.toString(); } public static String createForwards(List forwards) { StringBuilder sourceCode = new StringBuilder(); sourceCode.append("@Forwards( {"); sourceCode.append("\n"); int i; for (i = 0; i < (forwards.size() - 1); i++) { sourceCode.append(forwards.get(i)); sourceCode.append("," + "\n"); } sourceCode.append(forwards.get(i)); sourceCode.append("\n" + "} )"); return sourceCode.toString(); } }