1 package net.suberic.pooka; 2 import javax.mail.*; 3 import javax.mail.search.SearchTerm ; 4 import net.suberic.pooka.filter.FilterAction; 5 import java.util.List ; 6 7 11 public class MessageFilter { 12 private SearchTerm searchTerm; 13 private FilterAction action; 14 15 private String mProperty; 16 17 20 public MessageFilter(SearchTerm newSearchTerm, FilterAction newAction) { 21 searchTerm = newSearchTerm; 22 action = newAction; 23 } 24 25 30 public MessageFilter(String sourceProperty) { 31 mProperty = sourceProperty; 32 33 try { 34 searchTerm = Pooka.getSearchManager().generateSearchTermFromProperty(sourceProperty + ".searchTerm"); 35 36 action = generateFilterAction(sourceProperty + ".action"); 37 } catch (java.text.ParseException pe) { 38 40 pe.printStackTrace(); 41 } catch (InstantiationException ie) { 42 ie.printStackTrace(); 43 } catch (IllegalAccessException iae) { 44 iae.printStackTrace(); 45 } catch (ClassNotFoundException cnfe) { 46 cnfe.printStackTrace(); 47 } 48 } 49 50 53 public static FilterAction generateFilterAction(String actionProperty) throws ClassNotFoundException , InstantiationException , IllegalAccessException { 54 String className = Pooka.getProperty(actionProperty + ".class", ""); 55 Class filterClass = Class.forName(className); 56 FilterAction newAction = (FilterAction)filterClass.newInstance(); 57 newAction.initializeFilter(actionProperty); 58 return newAction; 59 } 60 61 63 public SearchTerm getSearchTerm() { 64 return searchTerm; 65 } 66 67 public void setSearchTerm(SearchTerm newTerm) { 68 searchTerm = newTerm; 69 } 70 71 public FilterAction getAction() { 72 return action; 73 } 74 75 public void setAction(FilterAction newAction) { 76 action=newAction; 77 } 78 79 82 public String getProperty() { 83 return mProperty; 84 } 85 } 86 | Popular Tags |