" link removing any "illegal" html tags
+ * @param haystack the url
+ * @param title the href link text
+ * @param imageRoot the place to find icons
+ * @param extImage the url of the icon to show next to the link
+ * @return a String containing the url
+ */
+ private String createURLLinks(String haystack, String title, String imageRoot, String extImage) {
+ if (title == null) {
+ return substituteAll(haystack, urlExpression,
+ " $0");
+ }
+
+ title = removeHTMLTags(title);
+
+ return substituteAll(haystack, urlExpression,
+ " " + title + "");
+ }
+
+ private String substituteAll(String anInput, Pattern anExpression, String aReplacement) {
+ Perl5Matcher matcher = new Perl5Matcher();
+
+ return Util.substitute(
+ matcher, anExpression,
+ new Perl5Substitution(aReplacement), anInput,
+ Util.SUBSTITUTE_ALL);
+ }
+
+ /**
+ * Remove all HTML tags
+ */
+ public String removeHTMLTags(String haystack){
+ return substituteAll(haystack, htmlTagExpression, "");
+ }
+
+
+ /**
+ * convertNewline2P ist eine regex-routine zum umwandeln von 2 oder mehr newlines (\n)
+ * in den html-tag
+ * nur sinnvoll, wenn text nicht im html-format eingegeben
+ */
+ private String convertNewline2P(String haystack) {
+ return substituteAll(haystack, doubleBRExpression, "\n
");
+ }
+
+ /**
+ * convertNewline2Break ist eine regex-routine zum umwandeln von 1 newline (\n)
+ * in den html-tag
+ * nur sinnvoll, wenn text nicht im html-format eingegeben
+ */
+ private String convertNewline2Break(String haystack) {
+ return substituteAll(haystack, newLineExpression, "$0
");
+ }
+
+
+ /**
+ * createMailLinks wandelt text im email-adressenformat
+ * in einen klickbaren link um
+ * nur sinnvoll, wenn text nicht im html-format eingegeben
+ */
+ private String createMailLinks(String haystack, String imageRoot, String mailImage) {
+ return substituteAll(haystack, emailAddressExpression,
+ " $0");
+ }
+
+
+ /**
+ * this routine takes text in url format and makes
+ * a clickaeble "" link removing any "illegal" html tags
+ * @param haystack the url
+ * @param imageRoot the place to find icons
+ * @param extImage the url of the icon to show next to the link
+ * @param intImage unused
+ * @return a String containing the url
+ */
+ private String createURLLinks(String haystack, String title, String imageRoot,String extImage, String intImage) {
+ return createURLLinks(haystack, title, imageRoot, extImage);
+ }
+
+ /**
+ */
+ public String createHTML(String content, String producerDocRoot, String mailImage, String extImage, String intImage){
+ content = convertNewline2Break(content);
+ content = convertNewline2P(content);
+ content = createMailLinks(content, producerDocRoot, mailImage);
+ content = createURLLinks(content, null, producerDocRoot,
+ extImage, intImage);
+
+ return content;
+ }
+
+
+}