00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 package dochelper;
00011
00012 import java.util.regex.MatchResult;
00013
00021 public class EscapedMatchTransformDefinition implements TransformDefinition {
00022
00023 private final String TEXT;
00024
00028 public EscapedMatchTransformDefinition(String text) {
00029 TEXT = text;
00030 }
00031
00051 public String render(MatchResult result) {
00052
00053 String strResult = this.getText();
00054
00055
00056 int groups = result.groupCount();
00057
00058
00059 for (int i = 0; i <= groups; i++) {
00060 String groupID = "\\$" + i;
00061 String groupText = result.group(i);
00062
00063
00064 groupText = escapeText(groupText);
00065 strResult = strResult.replaceAll(groupID, groupText);
00066 }
00067
00068 return strResult;
00069 }
00070
00080 public String escapeText(String text) {
00081
00082 return text.replace("\"", "'");
00083 }
00084
00092 public String getText() {
00093 return TEXT;
00094 }
00095 }