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 import java.util.LinkedList ; 7 import java.util.Iterator ; 8 9 15 public class BackendMessageFilter extends MessageFilter { 16 private SearchTerm searchTerm; 17 private FilterAction action; 18 19 22 public BackendMessageFilter(SearchTerm newSearchTerm, FilterAction newAction) { 23 super(newSearchTerm, newAction); 24 } 25 26 31 public BackendMessageFilter(String sourceProperty) { 32 super(sourceProperty); 33 } 34 35 42 public List filterMessages(List messages) { 43 return filterMessages(messages, null); 44 } 45 46 53 public List filterMessages(List messages, net.suberic.util.swing.ProgressDialog pd) { 54 List matches = new LinkedList (); 55 for (int i = 0; i < messages.size() && (pd == null || ! pd.isCancelled()); i++) { 56 57 if (getSearchTerm().match(((net.suberic.pooka.gui.MessageProxy)messages.get(i)).getMessageInfo().getMessage())) 58 matches.add(messages.get(i)); 59 60 if (pd != null) { 61 pd.setValue(pd.getValue() + 1); 62 } 63 } 64 65 if (pd == null || ! pd.isCancelled()) 66 return performFilter(matches); 67 else 68 return new LinkedList (); 69 } 70 71 79 public List performFilter(List filteredMessages) { 80 return getAction().performFilter(filteredMessages); 81 } 82 83 } 84 | Popular Tags |