Refactored some code

This commit is contained in:
Patrick Gotthard 2014-04-13 20:08:34 +02:00
parent 6fa6b2aec5
commit 0459e2f519

View file

@ -22,7 +22,6 @@ import java.io.InputStream;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
@ -114,28 +113,19 @@ public abstract class AbstractFeedFetcher implements FeedFetcher {
protected void fireEvent(final String eventType, final String urlStr, final SyndFeed feed) { protected void fireEvent(final String eventType, final String urlStr, final SyndFeed feed) {
final FetcherEvent fetcherEvent = new FetcherEvent(this, urlStr, eventType, feed); final FetcherEvent fetcherEvent = new FetcherEvent(this, urlStr, eventType, feed);
synchronized (fetcherEventListeners) { synchronized (fetcherEventListeners) {
final Iterator<FetcherListener> iter = fetcherEventListeners.iterator(); for (final FetcherListener fetcherEventListener : fetcherEventListeners) {
while (iter.hasNext()) {
final FetcherListener fetcherEventListener = iter.next();
fetcherEventListener.fetcherEvent(fetcherEvent); fetcherEventListener.fetcherEvent(fetcherEvent);
} }
} }
} }
/**
* @see com.sun.syndication.fetcher.FeedFetcher#addFetcherEventListener(com.sun.syndication.fetcher.FetcherListener)
*/
@Override @Override
public void addFetcherEventListener(final FetcherListener listener) { public void addFetcherEventListener(final FetcherListener listener) {
if (listener != null) { if (listener != null) {
fetcherEventListeners.add(listener); fetcherEventListeners.add(listener);
} }
} }
/**
* @see com.sun.syndication.fetcher.FeedFetcher#removeFetcherEventListener(com.sun.syndication.fetcher.FetcherListener)
*/
@Override @Override
public void removeFetcherEventListener(final FetcherListener listener) { public void removeFetcherEventListener(final FetcherListener listener) {
if (listener != null) { if (listener != null) {
@ -163,7 +153,7 @@ public abstract class AbstractFeedFetcher implements FeedFetcher {
* <p> * <p>
* Handles HTTP error codes. * Handles HTTP error codes.
* </p> * </p>
* *
* @param responseCode the HTTP response code * @param responseCode the HTTP response code
* @throws FetcherException if response code is in the range 400 to 599 inclusive * @throws FetcherException if response code is in the range 400 to 599 inclusive
*/ */
@ -192,11 +182,11 @@ public abstract class AbstractFeedFetcher implements FeedFetcher {
* <p> * <p>
* Combine the entries in two feeds into a single feed. * Combine the entries in two feeds into a single feed.
* </p> * </p>
* *
* <p> * <p>
* The returned feed will have the same data as the newFeed parameter, with the entries from originalFeed appended to the end of its entries. * The returned feed will have the same data as the newFeed parameter, with the entries from originalFeed appended to the end of its entries.
* </p> * </p>
* *
* @param originalFeed * @param originalFeed
* @param newFeed * @param newFeed
* @return * @return
@ -205,9 +195,7 @@ public abstract class AbstractFeedFetcher implements FeedFetcher {
SyndFeed result; SyndFeed result;
try { try {
result = (SyndFeed) newFeed.clone(); result = (SyndFeed) newFeed.clone();
result.getEntries().addAll(result.getEntries().size(), originalFeed.getEntries()); result.getEntries().addAll(result.getEntries().size(), originalFeed.getEntries());
return result; return result;
} catch (final CloneNotSupportedException e) { } catch (final CloneNotSupportedException e) {
final IllegalArgumentException iae = new IllegalArgumentException("Cannot clone feed"); final IllegalArgumentException iae = new IllegalArgumentException("Cannot clone feed");