package net.etouch.contmgmt.wiki; import net.etouch.contmgmt.common.CMUtils; /** * This class interpret's the value of the plugin defined. Child classes need to implement the abstract method defined in this class * translate(String regex, String content, String projectName, String title, String family, String ctx, String sessionId) */ abstract public class TemplateTagResolver implements WikiContentTranslator { /** * @param content * @param projectName * @param title * @param family * @param ctx * @param sessionId * @return */ public String translate(String content, String projectName, String title, String family, String ctx, String sessionId) { String matchPat = "()(.*?)(<\\s*/\\s*div\\s*>)"; content = translate(matchPat, content, projectName, title, family, ctx, sessionId); matchPat = "()(.*?)()"; content = translate(matchPat, content, projectName, title, family, ctx, sessionId); return content; } /** * @param regex * @param content * @param projectName * @param title * @param family * @param ctx * @param sessionId * @return */ abstract protected String translate(String regex, String content, String projectName, String title, String family, String ctx, String sessionId); /** * This method retrieves the value of the parameter's passed in the tag. This method need not be overridden. * @param str * @param attributeName * @return */ protected static String getAttributeValue(String str, String attributeName) { String value = null; try { if(str.indexOf(attributeName + "="") != -1) { value = (String) (CMUtils.getIndexStringCollection(str, attributeName + "="", """)).elementAt(0); if(value.trim().length() > 0) { value = value.trim(); } else { value = null; } } else if(str.indexOf(attributeName + "=\"") != -1) { value = (String) (CMUtils.getIndexStringCollection(str, attributeName + "=\"", "\"")).elementAt(0); if(value.trim().length() > 0) { value = value.trim(); } else { value = null; } } } catch(Exception _ex) { _ex.printStackTrace(); } return value; } }