Ejemplo n.º 1
0
 /**
  * @param html true if you want HTML output
  * @param rdf true if you want RDF/XML ouput
  * @param json true if you want JSON ouput
  * @param outputFolder where to place any HTML or RDF output
  * @param url The URL of the feed
  * @throws FileNotFoundException
  */
 public DemoItemListener(boolean html, boolean rdf, boolean json, String outputFolder, URL url)
     throws FileNotFoundException {
   super();
   this.html = html;
   this.rdf = rdf;
   this.json = json;
   setOutputFolder(outputFolder);
   this.baseFolder =
       this.outputFolder
           + DiskFeedInfoCache.replaceNonAlphanumeric(url.toExternalForm(), '_')
           + File.separator;
 }
Ejemplo n.º 2
0
  /** Handles the creation of the HTML and RDF files as required */
  private void saveFeedItems() {
    List<SyndEntry> itemList = this.getFeed().getEntries();

    for (SyndEntry entry : itemList) {
      printEntry(entry);
      if (!rdf && !html && !json) {
        continue;
      }
      String itemFileBase =
          baseFolder + DiskFeedInfoCache.replaceNonAlphanumeric(FeedHelper.getID(entry), '_');
      new File(baseFolder).mkdirs();

      if (json) {
        saveJSON(itemFileBase, entry);
      }
      if (rdf) {
        saveRDF(itemFileBase, entry);
      }
      if (html) {
        saveHTML(itemFileBase, entry, "feed-reader.properties");
      }
    }
  }