Package net.sf.jpluck.feed

Examples of net.sf.jpluck.feed.FeedFormatter


    } catch (Exception e) {
      InputStreamReader reader = new InputStreamReader(new ByteArrayInputStream(data), "ISO-8859-1");
      document = builder.parse(new InputSource(reader));
    }
    AtomFeed feed = new AtomFeed(document);
    FeedFormatter formatter = new FeedFormatter(feed, (Feed)jxl.getDocuments()[0]);
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.transform(new DOMSource(formatter.getIndexDocument()),
      new StreamResult(new File(file.getParentFile(),"index.html")));
    for (int i = 0, n = feed.getItems().length; i < n; i++) {
      transformer.transform(new DOMSource(formatter.getItemDocuments()[i]),
        new StreamResult(new File(file.getParentFile(),"item" + (i+1) + ".html")));
    }   
  }
View Full Code Here


        // Atom feed
        feed = new AtomFeed(dom);
      } else {   
        feed = new RSSFeed(dom);
      }
      FeedFormatter formatter = new FeedFormatter(feed, settings);
      boolean generateBookmarks = ClientConfiguration.getDefault().isGenerateBookmarks();
      if (settings.isUsePageStructure()) {
        FeedItem[] items = feed.getItems();
        for (int i = 0, n = items.length; i < n; i++) {
          String uri = resource.getURI() + "_item-" + (i + 1);
          TextRecord textRecord = new TextRecord(uri,
                               jxlDocument.getOutputEncoding(),
                               jxlDocument.isUseHiresMargins());
          HTMLSerializer serializer = new HTMLSerializer(textRecord, jxlDocument.getURIRewriter(),
                                   settings.getTextColorBrightness(), settings.isParseTables(),
                                   pluckerDocument);
          Transformer transformer = TransformerFactory.newInstance().newTransformer();
          transformer.transform(new DOMSource(formatter.getItemDocuments()[i]), new SAXResult(serializer));
          pluckerDocument.addRecord(serializer.getDataRecord());
         
          String[] pageURIs = serializer.getLinkURIs();
          for (int j = 0; j < pageURIs.length; j++) {
            if (!pageURIs[j].startsWith(resource.getURI() + "_item-")) {
              addPageLink(pageURIs[j]);
            }
          }

          String[] imageURIs = serializer.getEmbeddedImageURIs();
          for (int j = 0; j < imageURIs.length; j++) {
            addImageLink(imageURIs[j]);
          }

          if (generateBookmarks) {
            addBookmark(items[i], formatter, uri);         
          }
        }
      } else {
        FeedItem[] items = feed.getItems();
        for (int i = 0; i < items.length; i++) {
          FeedItem item = items[i];
          URIRewriter rewriter = jxlDocument.getURIRewriter();
          String uri = rewriter.rewrite(item.getURL());
          if (generateBookmarks && settings.isUseLinkStructure()) {
            addBookmark(items[i], formatter, uri);
          }
        }
      }

      Transformer transformer = TransformerFactory.newInstance().newTransformer();
      TextRecord textRecord = resource.createTextRecord(jxlDocument.getOutputEncoding(),
                                jxlDocument.isUseHiresMargins());
      TextRecordResult result = new TextRecordResult(textRecord, jxlDocument.getURIRewriter(),
                               settings.getTextColorBrightness(), settings.isParseTables(),
                               pluckerDocument);
      transformer.transform(new DOMSource(formatter.getIndexDocument()), result);
      pluckerDocument.addRecord(textRecord);
      if (settings.isUseLinkStructure() || settings.isUseListStructure()) {
        String[] pageURIs = result.getLinkURIs();
        for (int i = 0; i < pageURIs.length; i++) {
          addPageLink(pageURIs[i]);
View Full Code Here

TOP

Related Classes of net.sf.jpluck.feed.FeedFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.