| 1 10 package org.mmbase.util.transformers; 11 12 import java.util.*; 13 import java.util.regex.*; 14 import org.mmbase.util.Entry; 15 16 25 26 public class LinkFinder extends RegexpReplacer { 27 28 protected static Collection urlPatterns = new ArrayList(); 29 30 static { 31 new LinkFinder().readPatterns(urlPatterns); 32 } 33 34 public LinkFinder() { 35 super(XMLTEXT_WORDS); 36 } 37 38 39 protected String getConfigFile() { 40 return "linkfinder.xml"; 41 } 42 43 protected Collection getPatterns() { 44 return urlPatterns; 45 } 46 47 48 protected void readDefaultPatterns(Collection patterns) { 49 50 patterns.add(new Entry(Pattern.compile(".+@.+"), "<a HREF=\"mailto:$0\">$0</a>")); 51 patterns.add(new Entry(Pattern.compile("http://.+"), "<a HREF=\"$0\">$0</a>")); 52 patterns.add(new Entry(Pattern.compile("https://.+"), "<a HREF=\"$0\">$0</a>")); 53 patterns.add(new Entry(Pattern.compile("ftp://.+"), "<a HREF=\"$0\">$0</a>")); 54 patterns.add(new Entry(Pattern.compile("www\\..+"), "<a HREF=\"http://$0\">$0</a>")); 55 return; 56 } 57 58 59 public String toString() { 60 return "LINKFINDER"; 61 } 62 63 } 64 | Popular Tags |