net.sourceforge.rssowl.controller.thread
Class FeedDiscoveryManager

java.lang.Object
  extended bynet.sourceforge.rssowl.controller.thread.FeedDiscoveryManager

public class FeedDiscoveryManager
extends Object

The FeedDiscoveryManager performs a search for RSS / RDF feeds on a certain website. Each link that is in the result is checked for a valid feed. If the link is a newsfeed, a new line is added to the table of the FeedDiscoveryDialog.

Version:
1.1.3
Author:
Benjamin Pasero

Field Summary
private static int COLLECTOR_THREAD_COUNT
          Number of collector threads
(package private)  int collectorsDone
          Count the number of collector threads that have finished
private  ExtendedThread[] collectorThreads
          Collector threads to collect and parse links from the results of the search
private  Thread discoveryThread
          Thread that performs the search
private  Vector links
          List of links from the results
private static int MAX_CACHE_PER_RUN
          The maximum number of newsfeeds to cache per search
(package private)  Vector normalUrlObjects
          Synchronized list of normal URL objects
(package private)  org.jdom.input.SAXBuilder[] parser
          Create one parser for each Collector thread
(package private)  Vector preferredUrlObjects
          Synchronized list of preferred URL objects
(package private)  Random randomNumberGenerator
          Random Number Generator for sleep Time of Threads
private  int resultCounter
          Count the resulting Feeds
(package private)  FeedDiscoveryDialog rssOwlFeedDiscoveryDialog
          The opened rss feeddiscovery dialog
(package private)  boolean running
          Flag indicates the running threads
(package private)  boolean searchDone
          Flag indicates when the search has finished
private  URL webSiteURL
          Website to perform the search on
 
Constructor Summary
FeedDiscoveryManager(String webSiteURL, FeedDiscoveryDialog rssOwlFeedDiscoveryDialog)
          Instantiate a new FeedDiscoveryManager
 
Method Summary
(package private)  void buildChannel(URL url, int parserNumber)
          Build RSS channel object from the given URl
private  org.jdom.Document buildDocument(URL xmlUrl, boolean forceDefaultEncoding, int parserNumber)
          Build the XML document from the given URL
private  void createCollectorThreads()
          Collector thread checks if URLs in "urlObj" are RSS / RDF / Atom feeds
private  void createSearchThread()
          Search thread performs the search for the topic
private  void filterLink(String url)
          Filter the given link.
private  void initXMLParsers()
          Init one SAX Parser for each collector thread
 boolean isRunning()
          Get the state of the search
(package private)  void performSearch()
          Perform a search on the given website and add every link to the Stack, that was found.
 void startSearch()
          Start search- and collector threads
 void stopSearch()
          Interrupt the search- and collector threads
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLLECTOR_THREAD_COUNT

private static final int COLLECTOR_THREAD_COUNT
Number of collector threads

See Also:
Constant Field Values

MAX_CACHE_PER_RUN

private static final int MAX_CACHE_PER_RUN
The maximum number of newsfeeds to cache per search

See Also:
Constant Field Values

collectorThreads

private ExtendedThread[] collectorThreads
Collector threads to collect and parse links from the results of the search


discoveryThread

private Thread discoveryThread
Thread that performs the search


links

private Vector links
List of links from the results


resultCounter

private int resultCounter
Count the resulting Feeds


webSiteURL

private URL webSiteURL
Website to perform the search on


collectorsDone

int collectorsDone
Count the number of collector threads that have finished


normalUrlObjects

Vector normalUrlObjects
Synchronized list of normal URL objects


parser

org.jdom.input.SAXBuilder[] parser
Create one parser for each Collector thread


preferredUrlObjects

Vector preferredUrlObjects
Synchronized list of preferred URL objects


randomNumberGenerator

Random randomNumberGenerator
Random Number Generator for sleep Time of Threads


rssOwlFeedDiscoveryDialog

FeedDiscoveryDialog rssOwlFeedDiscoveryDialog
The opened rss feeddiscovery dialog


running

boolean running
Flag indicates the running threads


searchDone

boolean searchDone
Flag indicates when the search has finished

Constructor Detail

FeedDiscoveryManager

public FeedDiscoveryManager(String webSiteURL,
                            FeedDiscoveryDialog rssOwlFeedDiscoveryDialog)
                     throws MalformedURLException
Instantiate a new FeedDiscoveryManager

Parameters:
webSiteURL - The website to perform the search on
rssOwlFeedDiscoveryDialog - This dialog called the FeedSearchManager
Throws:
MalformedURLException - In case the URL is malformed
Method Detail

isRunning

public boolean isRunning()
Get the state of the search

Returns:
boolean TRUE if search is running

startSearch

public void startSearch()
Start search- and collector threads


stopSearch

public void stopSearch()
Interrupt the search- and collector threads


buildDocument

private org.jdom.Document buildDocument(URL xmlUrl,
                                        boolean forceDefaultEncoding,
                                        int parserNumber)
Build the XML document from the given URL

Parameters:
xmlUrl - The XML Url object
forceDefaultEncoding - If set to TRUE the encoding is not being detected from the XMl document and the OS default encoding is used
parserNumber - The number of the index in the parser array to use
Returns:
Document The builded XML document from the URL or NULL on warning

createCollectorThreads

private void createCollectorThreads()
Collector thread checks if URLs in "urlObj" are RSS / RDF / Atom feeds


createSearchThread

private void createSearchThread()
Search thread performs the search for the topic


filterLink

private void filterLink(String url)
                 throws MalformedURLException
Filter the given link. Do not add URLs which have a file name which marks them as binary file. Create absolute links from relative ones.

Parameters:
url - Any URL to filter
Throws:
MalformedURLException - In case the URL is not valid

initXMLParsers

private void initXMLParsers()
Init one SAX Parser for each collector thread


buildChannel

void buildChannel(URL url,
                  int parserNumber)
Build RSS channel object from the given URl

Parameters:
url - The URL of the newsfeed
parserNumber - The number of the index in the parser array to use

performSearch

void performSearch()
             throws IOException
Perform a search on the given website and add every link to the Stack, that was found. Each link is first filtered, to see if it's not an image or zip for example.

Throws:
IOException - If connection fails


RSSOwl - RSS / RDF / Atom Newsreader

SourceForge.net Logo