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
-
currentlyRunning
-
-
currentParsers
-
-
maxThreadNum
-
-
threadSyncObj
-
-
todoPool
-
-
Parsers(FIFOQueue)
- Prepares a new ThreadGroup for the Parsers.
-
getCounter()
-
-
getParsingNodes()
-
-
newNode(URLNode)
- Called by a Parser-thread that found a new node
-
nodeDone(Parser, HTMLNode)
- Called by a Parser-thread that finished parsing a node
-
setMaxThreadNum(int)
- Sets the maximum number of allowed threads.
-
startThread()
- Starts a new Thread that parses the next node from the todo-pool (if available).
-
stopAll()
-
Stops all the Parser-threads.
-
update(Observable, Object)
- Called when a node was added to the todo-pool
todoPool
private FIFOQueue todoPool
maxThreadNum
private int maxThreadNum
threadSyncObj
private Object threadSyncObj
currentlyRunning
private int currentlyRunning
currentParsers
private Vector currentParsers
Parsers
public Parsers(FIFOQueue todoPool)
- Prepares a new ThreadGroup for the Parsers. To set the maximum number of threads,
use the method setMaxThreadNum(num).
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)
startThread
public synchronized void startThread()
- Starts a new Thread that parses the next node from the todo-pool (if available).
update
public synchronized void update(Observable o,
Object message)
- Called when a node was added to the todo-pool
newNode
protected synchronized void newNode(URLNode n)
- Called by a Parser-thread that found a new node
nodeDone
protected synchronized void nodeDone(Parser p,
HTMLNode n)
- Called by a Parser-thread that finished parsing a node
getCounter
public int getCounter()
- Returns:
- The number of currently running Parser-threads.
getParsingNodes
public Vector getParsingNodes()
- Returns:
- a Vector filled with the nodes that are currently parsed by the Parser-threads
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