net.sourceforge.rssowl.controller.thread
Class FeedSearchManager

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

public class FeedSearchManager
extends Object

The FeedSearchManager performs a search for RSS / RDF feeds on a certain topic. 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 FeedSearchDialog.

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  boolean intensiveSearch
          If TRUE parse any link from the results.
private  Vector links
          List of links from the results
private static Vector localeSearchList
          Domains that are allowed to use for search
private static int MAX_CACHE_PER_RUN
          The maximum number of newsfeeds to cache per search
private  boolean nativeLangSearch
          If TRUE only display news that match the selected language
private static String NEXT_IMAGE
          Token for next image
(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)  FeedSearchDialog rssOwlFeedSearchDialog
          The opened rss feedsearch dialog
(package private)  boolean running
          Flag indicates the running threads
private static String[] SEARCH_DELIMITER
          One of the words from this array is combined with the search of the user
(package private)  boolean searchDone
          Flag indicates when the search has finished
private  Thread searchThread
          Thread that performs the search
private  String searchUrl
          URL to get the results from
private static String START_PARAM
          Token for start parameter
private  String topic
          Topic that the user searches for
 
Constructor Summary
FeedSearchManager(String topic, FeedSearchDialog rssOwlFeedSearchDialog, boolean intensiveSearch, boolean nativeLangSearch)
          Instantiate a new FeedSearchManager
 
Method Summary
static void addIntoLocaleSearchList(String value)
          Add a value to the locale search list
(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 valid RSS / RDF feeds
private  void createSearchThread()
          Search thread performs the search for the topic
private  String createUrl()
          Create the URL to perform the search
private  void filterLink(String url)
          Filter the given URL.
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 search engine 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

localeSearchList

private static final Vector localeSearchList
Domains that are allowed to use for search


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

NEXT_IMAGE

private static final String NEXT_IMAGE
Token for next image

See Also:
Constant Field Values

SEARCH_DELIMITER

private static final String[] SEARCH_DELIMITER
One of the words from this array is combined with the search of the user


START_PARAM

private static final String START_PARAM
Token for start parameter

See Also:
Constant Field Values

collectorThreads

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


intensiveSearch

private boolean intensiveSearch
If TRUE parse any link from the results. If FALSE parse .xml, .rss and .rdf


links

private Vector links
List of links from the results


nativeLangSearch

private boolean nativeLangSearch
If TRUE only display news that match the selected language


resultCounter

private int resultCounter
Count the resulting Feeds


searchThread

private Thread searchThread
Thread that performs the search


searchUrl

private String searchUrl
URL to get the results from


topic

private String topic
Topic that the user searches for


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


rssOwlFeedSearchDialog

FeedSearchDialog rssOwlFeedSearchDialog
The opened rss feedsearch dialog


running

boolean running
Flag indicates the running threads


searchDone

boolean searchDone
Flag indicates when the search has finished

Constructor Detail

FeedSearchManager

public FeedSearchManager(String topic,
                         FeedSearchDialog rssOwlFeedSearchDialog,
                         boolean intensiveSearch,
                         boolean nativeLangSearch)
Instantiate a new FeedSearchManager

Parameters:
topic - Topic to search for
rssOwlFeedSearchDialog - This dialog called the FeedSearchManager
intensiveSearch - TRUE if intensive search is performed
nativeLangSearch - TRUE if native lang search is performed
Method Detail

addIntoLocaleSearchList

public static void addIntoLocaleSearchList(String value)
Add a value to the locale search list

Parameters:
value - The value to add

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 valid RSS / RDF feeds


createSearchThread

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


createUrl

private String createUrl()
Create the URL to perform the search

Returns:
String search URL

filterLink

private void filterLink(String url)
Filter the given URL. Do not add URLs which have a file name which marks them as binary file

Parameters:
url - Any URL to filter

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 search engine 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