+package pnews.servlet;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonObject;
+
+import pnews.Category;
+import pnews.Feed;
+
+public class Config {
+ public static Feed[] getFeeds() {
+ Reader r;
+ List<Feed> feeds;
+ JsonObject jfeeds;
+
+ r = null;
+ try {
+ r = new InputStreamReader(Config.class.getClassLoader().getResourceAsStream("feeds.json"));
+ jfeeds = Json.createReader(r).readObject();
+ } finally {
+ if (r != null)
+ try { r.close(); } catch (IOException e) { };
+ }
+
+ feeds = new ArrayList<Feed>(jfeeds.size());
+
+ jfeeds.forEach((k, v)-> {
+ JsonObject jf;
+ JsonArray jcategories;
+
+ jf = (JsonObject)v;
+ jcategories = jf.getJsonArray("categories");
+ feeds.add(new Feed(k, Category.valueOf(jcategories.getString(0))));
+ });
+
+ return feeds.toArray(new Feed[] {});
+ }
+
+ public static Map<Category, String[]> getFeedsByCategory() {
+ Map<Category, String[]> result;
+
+ result = new HashMap<>();
+
+ result.put(Category.ACTUALITE,
+ new String[] {
+ "http://www.europe1.fr/var/export/rss/europe1/actus.xml",
+ "http://www.francetvinfo.fr/titres.rss",
+ "http://www.rfi.fr/general/rss",
+ "http://www.cnews.fr/rss/une",
+ "http://www.ladepeche.fr/rss/a-la-une.rss",
+ "https://www.franceinter.fr/rss/a-la-une.xml",
+ "https://www.francebleu.fr/rss/a-la-une.xml",
+ "http://www.bfmtv.com/rss/info/flux-rss/flux-toutes-les-actualites/"
+ });
+
+ result.put(Category.SPORT,
+ new String[] { "http://www.europe1.fr/var/export/rss/europe1/sport.xml",
+ "http://www.sportune.fr/feed",
+ "http://www.france24.com/fr/sports/rss" });
+
+ result.put(Category.FRANCE,
+ new String[] { "http://www.france24.com/fr/france/rss",
+ "http://www.francetvinfo.fr/france.rss",
+ "http://www.rfi.fr/france/rss"});
+
+ result.put(Category.EUROPE,
+ new String[] { "http://www.france24.com/fr/europe/rss" });
+
+ result.put(Category.MONDE,
+ new String[] { "http://www.europe1.fr/var/export/rss/europe1/international.xml",
+ "http://www.france24.com/fr/actualites/rss" });
+
+
+ result.put(Category.ECONOMIE,
+ new String[] { "http://www.france24.com/fr/economie/rss",
+ "http://www.europe1.fr/var/export/rss/europe1/economie.xml",
+ "http://www.rfi.fr/economie/rss" });
+
+ result.put(Category.ESSONNE,
+ new String[] { "http://www.tourisme-essonne.com/rss/actus/",
+ "http://www.ville-palaiseau.fr/rss/actualites.htm" });
+
+ result.put(Category.PEOPLE,
+ new String[] { "http://www.premiere.fr/rss/actu-live",
+ "http://www.purepeople.com/rss/news_t0.xml"
+ });
+
+ result.put(Category.TECHNOLOGIE,
+ new String[] { "http://www.generation-nt.com/export/rss.xml",
+ "http://www.europe1.fr/var/export/rss/europe1/sciences.xml",
+ "http://feeds.feedburner.com/lesnumeriques/news",
+ "http://www.zdnet.fr/feeds/rss/actualites/",
+ "http://www.frandroid.com/feed",
+ "http://www.silicon.fr/feed",
+ "http://www.fredzone.org/feed",
+ "http://www.futura-sciences.com/rss/actualites.xml",
+ "https://www-03.ibm.com/press/fr/fr/rssfeed.wss?keyword=null&maxFeed=&feedType=RSS&topic=all"});
+
+ return result;
+ }
+
+ public static void main(String[] args) {
+ Feed[] feeds;
+
+ feeds = getFeeds();
+
+ System.out.println("Number of feeds: " + feeds.length);
+ for (Feed f: feeds)
+ System.out.println(f);
+ }
+}