1 28 package de.nava.informa.utils.poller; 29 30 import de.nava.informa.core.ChannelIF; 31 import de.nava.informa.core.ItemIF; 32 33 import java.util.List ; 34 import java.util.Vector ; 35 36 41 class CompositeObserver implements PollerObserverIF { 42 private List observers = new Vector (); 43 44 51 public final void itemFound(ItemIF item, ChannelIF channel) { 52 final int size = observers.size(); 53 for (int i = 0; i < size; i++) { 54 final PollerObserverIF observer = (PollerObserverIF) observers.get(i); 55 try { 56 observer.itemFound(item, channel); 57 } catch (RuntimeException e) { 58 } 60 } 61 } 62 63 69 public final void channelErrored(ChannelIF channel, Exception e) { 70 final int size = observers.size(); 71 for (int i = 0; i < size; i++) { 72 final PollerObserverIF observer = (PollerObserverIF) observers.get(i); 73 try { 74 observer.channelErrored(channel, e); 75 } catch (RuntimeException e1) { 76 } 78 } 79 } 80 81 86 public final void channelChanged(ChannelIF channel) { 87 final int size = observers.size(); 88 for (int i = 0; i < size; i++) { 89 final PollerObserverIF observer = (PollerObserverIF) observers.get(i); 90 try { 91 observer.channelChanged(channel); 92 } catch (RuntimeException e1) { 93 } 95 } 96 } 97 98 103 public final void pollStarted(ChannelIF channel) { 104 final int size = observers.size(); 105 for (int i = 0; i < size; i++) { 106 final PollerObserverIF observer = (PollerObserverIF) observers.get(i); 107 try { 108 observer.pollStarted(channel); 109 } catch (RuntimeException e1) { 110 } 112 } 113 } 114 115 120 public final void pollFinished(ChannelIF channel) { 121 final int size = observers.size(); 122 for (int i = 0; i < size; i++) { 123 final PollerObserverIF observer = (PollerObserverIF) observers.get(i); 124 try { 125 observer.pollFinished(channel); 126 } catch (RuntimeException e1) { 127 } 129 } 130 } 131 132 137 public final void add(PollerObserverIF observer) { 138 if (!observers.contains(observer)) { 139 observers.add(observer); 140 } 141 } 142 143 148 public final void remove(PollerObserverIF observer) { 149 observers.remove(observer); 150 } 151 } 152 | Popular Tags |