All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Webcrawler.Crawler.Parsers

java.lang.Object
   |
   +----java.util.Observable
           |
           +----Webcrawler.Crawler.Parsers

public class Parsers
extends Observable
implements Observer
This class manages a group of Parsers-threads. Whenever something is added to the todoPool, or when a Parser is done, it checks if a new Parser-thread can me started and does so if possible. Sends out ParsersMessages

See Also:
ParsersMessage

Variable Index

 o currentlyRunning
 o currentParsers
 o maxThreadNum
 o threadSyncObj
 o todoPool

Constructor Index

 o Parsers(FIFOQueue)
Prepares a new ThreadGroup for the Parsers.

Method Index

 o getCounter()
 o getParsingNodes()
 o newNode(URLNode)
Called by a Parser-thread that found a new node
 o nodeDone(Parser, HTMLNode)
Called by a Parser-thread that finished parsing a node
 o setMaxThreadNum(int)
Sets the maximum number of allowed threads.
 o startThread()
Starts a new Thread that parses the next node from the todo-pool (if available).
 o stopAll()
Stops all the Parser-threads.
 o update(Observable, Object)
Called when a node was added to the todo-pool

Variables

 o todoPool
 private FIFOQueue todoPool
 o maxThreadNum
 private int maxThreadNum
 o threadSyncObj
 private Object threadSyncObj
 o currentlyRunning
 private int currentlyRunning
 o currentParsers
 private Vector currentParsers

Constructors

 o Parsers
 public Parsers(FIFOQueue todoPool)
Prepares a new ThreadGroup for the Parsers. To set the maximum number of threads, use the method setMaxThreadNum(num).

Methods

 o setMaxThreadNum
 public void setMaxThreadNum(int maxThreadNum)
Sets the maximum number of allowed threads. Since no computer-system can have an infinite number of threads this is important. The default number is 1 (set by the constructor)

 o startThread
 public synchronized void startThread()
Starts a new Thread that parses the next node from the todo-pool (if available).

 o update
 public synchronized void update(Observable o,
                                 Object message)
Called when a node was added to the todo-pool

 o newNode
 protected synchronized void newNode(URLNode n)
Called by a Parser-thread that found a new node

 o nodeDone
 protected synchronized void nodeDone(Parser p,
                                      HTMLNode n)
Called by a Parser-thread that finished parsing a node

 o getCounter
 public int getCounter()
Returns:
The number of currently running Parser-threads.
 o getParsingNodes
 public Vector getParsingNodes()
Returns:
a Vector filled with the nodes that are currently parsed by the Parser-threads
 o stopAll
 public void stopAll()
Stops all the Parser-threads. e.g. called when the user presses the Stop-button.


All Packages  Class Hierarchy  This Package  Previous  Next  Index