Source:
public static String transformText(String origText, ExtendedEmailPublisherContext context, List<TokenMacro> additionalMacros) { if(StringUtils.isBlank(origText)) return ""; String defaultContent = Matcher.quoteReplacement(noNull(context.getPublisher().defaultContent)); String defaultSubject = Matcher.quoteReplacement(noNull(context.getPublisher().defaultSubject)); String defaultReplyTo = Matcher.quoteReplacement(noNull(context.getPublisher().replyTo)); String defaultBody = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultBody())); String defaultExtSubject = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultSubject())); String defaultRecipients = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultRecipients())); String defaultExtReplyTo = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultReplyTo())); String defaultPresendScript = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultPresendScript())); String newText = origText.replaceAll( PROJECT_DEFAULT_BODY, defaultContent).replaceAll( PROJECT_DEFAULT_SUBJECT, defaultSubject).replaceAll( PROJECT_DEFAULT_REPLYTO, defaultReplyTo).replaceAll( DEFAULT_BODY, defaultBody).replaceAll( DEFAULT_SUBJECT, defaultExtSubject).replaceAll( DEFAULT_RECIPIENTS, defaultRecipients).replaceAll( DEFAULT_REPLYTO, defaultExtReplyTo).replaceAll( DEFAULT_PRESEND_SCRIPT, defaultPresendScript); try { List<TokenMacro> macros = new ArrayList<TokenMacro>(getPrivateMacros()); if(additionalMacros != null) macros.addAll(additionalMacros); if(context.getBuild() != null) { newText = TokenMacro.expandAll(context.getBuild(), context.getListener(), newText, false, macros); } } catch (MacroEvaluationException e) { context.getListener().getLogger().println("Error evaluating token: " + e.getMessage()); } catch (Exception e) { Logger.getLogger(ContentBuilder.class.getName()).log(Level.SEVERE, null, e); } return newText; }

Target:
public static String transformText(String origText, ExtendedEmailPublisherContext context, List<TokenMacro> additionalMacros) { if(StringUtils.isBlank(origText)) return ""; String defaultContent = Matcher.quoteReplacement(noNull(context.getPublisher().defaultContent)); String defaultSubject = Matcher.quoteReplacement(noNull(context.getPublisher().defaultSubject)); String defaultReplyTo = Matcher.quoteReplacement(noNull(context.getPublisher().replyTo)); String defaultBody = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultBody())); String defaultExtSubject = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultSubject())); String defaultRecipients = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultRecipients())); String defaultExtReplyTo = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultReplyTo())); String defaultPresendScript = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultPresendScript())); String defaultPostsendScript = Matcher.quoteReplacement(noNull(context.getPublisher().getDescriptor().getDefaultPostsendScript())); String newText = origText.replaceAll( PROJECT_DEFAULT_BODY, defaultContent).replaceAll( PROJECT_DEFAULT_SUBJECT, defaultSubject).replaceAll( PROJECT_DEFAULT_REPLYTO, defaultReplyTo).replaceAll( DEFAULT_BODY, defaultBody).replaceAll( DEFAULT_SUBJECT, defaultExtSubject).replaceAll( DEFAULT_RECIPIENTS, defaultRecipients).replaceAll( DEFAULT_REPLYTO, defaultExtReplyTo).replaceAll( DEFAULT_PRESEND_SCRIPT, defaultPresendScript).replaceAll( DEFAULT_POSTSEND_SCRIPT, defaultPostsendScript); try { List<TokenMacro> macros = new ArrayList<TokenMacro>(getPrivateMacros()); if(additionalMacros != null) macros.addAll(additionalMacros); if(context.getBuild() != null) { newText = TokenMacro.expandAll(context.getBuild(), context.getListener(), newText, false, macros); } } catch (MacroEvaluationException e) { context.getListener().getLogger().println("Error evaluating token: " + e.getMessage()); } catch (Exception e) { Logger.getLogger(ContentBuilder.class.getName()).log(Level.SEVERE, null, e); } return newText; }