1 28 package de.nava.informa.utils.cleaner; 29 30 import de.nava.informa.utils.toolkit.WorkerThread; 31 import de.nava.informa.utils.toolkit.ChannelRecord; 32 import de.nava.informa.core.ChannelIF; 33 import de.nava.informa.core.ItemIF; 34 35 46 public class CleanerWorkerThread extends WorkerThread { 47 48 private CleanerObserverIF observer; 49 private CleanerMatcherIF matcher; 50 51 57 public CleanerWorkerThread(CleanerObserverIF observer, CleanerMatcherIF matcher) { 58 super("Cleaner - Worker thread"); 59 60 this.observer = observer; 61 this.matcher = matcher; 62 } 63 64 69 protected final void processRecord(ChannelRecord record) { 70 if (matcher != null && observer != null) { 71 final ChannelIF channel = record.getChannel(); 72 73 observer.cleaningStarted(channel); 74 75 final ItemIF[] items = (ItemIF[]) channel.getItems().toArray(new ItemIF[0]); 76 for (int i = 0; i < items.length; i++) { 77 checkItem(items[i], channel); 78 } 79 80 observer.cleaningFinished(channel); 81 } 82 } 83 84 90 private void checkItem(ItemIF item, ChannelIF channel) { 91 if (matcher.isMatching(item, channel)) { 92 try { 93 observer.unwantedItem(item, channel); 94 } catch (Exception e) { 95 } 97 } 98 } 99 } 100 | Popular Tags |