|
|||||||||||||||||||
| This license of Clover is provided to support the development of Flock only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover. | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| FeedLoader.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
package net.sf.flock.parser; |
|
| 2 |
|
|
| 3 |
import net.sf.flock.FeedFactoryI; |
|
| 4 |
import net.sf.flock.FeedI; |
|
| 5 |
import net.sf.flock.FlockResourceException; |
|
| 6 |
import net.sf.flock.SubscriptionInfoI; |
|
| 7 |
|
|
| 8 |
import org.apache.log4j.LogManager; |
|
| 9 |
import org.apache.log4j.Logger; |
|
| 10 |
import org.jdom.Document; |
|
| 11 |
|
|
| 12 |
public class FeedLoader {
|
|
| 13 |
|
|
| 14 |
private final static Logger LOGGER = LogManager.getLogger(FeedLoader.class); |
|
| 15 |
|
|
| 16 |
private final FeedFactoryI feedFactory; |
|
| 17 |
|
|
| 18 |
private FeedParserI[] parsers = new FeedParserI[] {
|
|
| 19 |
new Rss091Parser(), |
|
| 20 |
new Rss20Parser(), |
|
| 21 |
new Rss10Parser() |
|
| 22 |
}; |
|
| 23 |
|
|
| 24 | 0 |
public FeedLoader(FeedFactoryI feedFactory) {
|
| 25 | 0 |
this.feedFactory = feedFactory; |
| 26 |
} |
|
| 27 |
|
|
| 28 | 0 |
public FeedI parseFeed(SubscriptionInfoI subscriptionInfo, Document doc) throws FlockResourceException {
|
| 29 | 0 |
for (int i=0; i<parsers.length; i++) {
|
| 30 | 0 |
if (parsers[i].isSuitable(doc)) {
|
| 31 | 0 |
LOGGER.info("load feed["+subscriptionInfo.getLocation()+"] with parser "+parsers[i].getClass().getName());
|
| 32 | 0 |
return parsers[i].parse(subscriptionInfo, this.feedFactory, doc); |
| 33 |
} |
|
| 34 |
} |
|
| 35 |
|
|
| 36 | 0 |
throw new UnsupportedFeedFormatException("Unsupported feed format");
|
| 37 |
} |
|
| 38 |
|
|
| 39 |
} |
|
| 40 |
|
|
||||||||||