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 public FeedLoader(FeedFactoryI feedFactory) {
25 this.feedFactory = feedFactory;
26 }
27
28 public FeedI parseFeed(SubscriptionInfoI subscriptionInfo, Document doc) throws FlockResourceException {
29 for (int i=0; i<parsers.length; i++) {
30 if (parsers[i].isSuitable(doc)) {
31 LOGGER.info("load feed["+subscriptionInfo.getLocation()+"] with parser "+parsers[i].getClass().getName());
32 return parsers[i].parse(subscriptionInfo, this.feedFactory, doc);
33 }
34 }
35
36 throw new UnsupportedFeedFormatException("Unsupported feed format");
37 }
38
39 }
This page was automatically generated by Maven