1 17 18 package org.apache.james.transport.matchers; 19 20 import org.apache.oro.text.regex.MalformedPatternException; 21 import org.apache.james.util.RFC2822Headers; 22 import javax.mail.MessagingException ; 23 24 28 public class FileRegexMatcher extends GenericRegexMatcher { 29 public void init() throws MessagingException { 30 try { 31 java.io.RandomAccessFile patternSource = new java.io.RandomAccessFile (getCondition(), "r"); 32 int lines = 0; 33 while(patternSource.readLine() != null) lines++; 34 patterns = new Object [lines][2]; 35 patternSource.seek(0); 36 for (int i = 0; i < lines; i++) { 37 String line = patternSource.readLine(); 38 patterns[i][0] = line.substring(0, line.indexOf(':')); 39 patterns[i][1] = line.substring(line.indexOf(':')+1); 40 } 41 compile(patterns); 42 } 43 catch (java.io.FileNotFoundException fnfe) { 44 throw new MessagingException ("Could not locate patterns.", fnfe); 45 } 46 catch (java.io.IOException ioe) { 47 throw new MessagingException ("Could not read patterns.", ioe); 48 } 49 catch(MalformedPatternException mp) { 50 throw new MessagingException ("Could not initialize regex patterns", mp); 51 } 52 } 53 } 54 | Popular Tags |