public void setFeed(Feed feed) {
   MySeriesLogger.logger.log(Level.INFO, "Setting feed to {0}", feed);
   this.feed = feed;
   removeAll();
   feedPanel = new MyScrollableFlowPanel();
   JScrollPane panel = new JScrollPane(feedPanel);
   panel.getViewport().setOpaque(false);
   panel.setOpaque(false);
   feedPanel.setOpaque(false);
   panel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
   add(panel, BorderLayout.CENTER);
   feedPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
   int count = 0;
   MySeriesLogger.logger.log(Level.INFO, "Creating {0} feed entries", feed.getEntries().size());
   for (Iterator<SyndEntryImpl> it = feed.getEntries().iterator(); it.hasNext(); ) {
     SyndEntryImpl entry = it.next();
     FeedPanel p = new FeedPanel(feedPanel, entry, this);
     p.run();
     count++;
   }
   revalidate();
   repaint();
 }
Пример #2
0
  public void run() {
    while (true) {

      try {
        // System.out.println(r+": Take(wait)");
        // String[] info = q.take();
        String blogID = q.poll(60, TimeUnit.SECONDS);
        if (blogID == null) {
          System.out.println("Poll.Timeout");
          continue;
        }

        // System.out.println(r+": Take(get) : "+blogID);

        if (blogID == NO_MORE_WORK) {
          break;
        }

        URL feedUrl = new URL("http://www.blogger.com/feeds/" + blogID + "/comments/default");
        Query myQuery = new Query(feedUrl);
        myQuery.setMaxResults(25);

        System.out.print(r + "+,");
        Feed resultFeed = myService.query(myQuery, Feed.class);

        for (Entry entry : resultFeed.getEntries()) {
          if (entry.getAuthors().get(0).getUri() != null) {
            String profileID = entry.getAuthors().get(0).getUri().replaceAll("[^\\d]", "");
            if (profileID.length() == 20) {
              try {
                myStm.executeUpdate(
                    "INSERT IGNORE INTO author SET profileID = '" + profileID + "'");
                // System.out.print(r+"+,");
              } catch (Exception e) {
              }
            }
          }
        }

      } catch (Exception e) {
        System.out.print(r + "ERR,");
      }
    }

    System.out.println("Bye(" + r + ")");
    try {
      myStm.close();
    } catch (Exception e) {
    }
  }