All Packages Class Hierarchy This Package Previous Next Index
Class Webcrawler.Controller.Controller
java.lang.Object
|
+----Webcrawler.Controller.Controller
- public abstract class Controller
- extends Object
- implements ControllerInterface, ActionListener, ChangeListener
This is the abstract superclass of all controllers for the Webcrawler. It provides
the general settings such as the Start-URL, the maximum crawl-depth and more advanced
settings like the max. number of Reader/Parser-Threads or the Start-Time. When creating a new
Controller object a window is created that contains tabs for the different settings.
A subclass of this class should add at least one tab for the specific settings of that
particular Controller. The controller creates a new Crawler-object which is told to start
when the user presses the Start-Button.
This class implements the ControllerInterface, so that it can communicate with the Crawler.
When deriving new Controllers from this one, don't forget to call the "super" methods in
all methods and constructors.
Currently available controllers: Grabber, StringFinder
- See Also:
- ControllerInterface, Grabber, StringFinder
-
crawler
- This is the one and only Crawler of the Webcrawler-Application.
-
crawlerStarted
-
-
currTimeLabel
-
-
enableMaxTimeBox
-
-
enableStartTimeBox
-
-
frame
-
-
helpMenu
- Subclasses should add a MenuItem for their specific help here.
-
info
-
-
maxDepthField
-
-
maxNodeNumField
-
-
maxThreadNumSlider
-
-
maxTimeField
-
-
maxTimeLabel
-
-
mb
-
-
nest
-
-
nodesInTree
-
-
nodesLoaded
-
-
onlySameHostBox
-
-
openIcon
-
-
pasteIcon
-
-
play1Icon
-
-
play2Icon
-
-
play3Icon
-
-
progressBar
-
-
rootURLField
-
-
saveIcon
-
-
secondsOver
-
-
startButton
-
-
startHost
-
-
startTimeField
-
-
startTimeLabel
-
-
stop1Icon
-
-
stop2Icon
-
-
stop3Icon
-
-
stopButton
-
-
tabbedPane
- The tabbedPane that subclasses should ad their controller-specific tab to
For example see one of the standard controllers like the "StringFinder"
-
userStarted
-
-
Controller()
-
This constructor creates a new Crawler-object which is started by pressing the Start-Button
in the "General" tab.
-
actionPerformed(ActionEvent)
- Catches the ActionEvents when one of the buttons in the "General"-tab was pressed
always call super.actionEvent(e) in subclasses at the end of the subclass' method
-
addedANode(URLNode)
- When a new node is added to the tree, the Crawler calls this method to let
the Controller know.
-
crawlerDone()
-
Called by the Crawler when its work is done.
-
everySecond()
- Called by the NotifyEverySecond-thread once a second.
-
getCrawler()
- This mehod can be used by the surrounding application for attaching visualizers to
the Crawler - since the crawler is being created by the controller.
-
loadCurrSettings()
- Loads the settings for the current Controller window.
-
loadLink(LoadableNode)
- Subclasses should implement this mehtod.
-
localFileName(LoadableNode)
- Before the Crawler sends a node to the todo-pool for being downloaded, it asks
the controller, through this method, under what filename the downloaded data
should be stored locally.
-
nodeDone(URLNode)
- Called by the Crawler when the node n is done (=loaded).
-
nodeLoaded(URLNode)
- When the Crawler gets a node back from a Reader (= when the data has
been downloaded) the Crawler notifies the Controller, via this method.
-
saveCurrSettings()
- Saves the settings in the current Controller window.
-
startCrawler()
- Tells the Crawler the maximum number of allowed Reader-threads and starts the Crawler.
-
stateChanged(ChangeEvent)
- Catches the ChangeEvents when one of the Checkboxes int the "Advanced"-tab was clicked
-
stopCrawler()
- Stops the Crawler
-
willSonsBeLoaded(HTMLNode)
- Says if n's sons will be loaded in the future.
play1Icon
static ImageIcon play1Icon
play2Icon
static ImageIcon play2Icon
play3Icon
static ImageIcon play3Icon
stop1Icon
static ImageIcon stop1Icon
stop2Icon
static ImageIcon stop2Icon
stop3Icon
static ImageIcon stop3Icon
saveIcon
static ImageIcon saveIcon
openIcon
static ImageIcon openIcon
pasteIcon
static ImageIcon pasteIcon
crawler
protected Crawler crawler
- This is the one and only Crawler of the Webcrawler-Application. It is created by this
Controller.
nodesInTree
protected int nodesInTree
nodesLoaded
protected int nodesLoaded
frame
protected JFrame frame
mb
protected JMenuBar mb
helpMenu
protected JMenu helpMenu
- Subclasses should add a MenuItem for their specific help here.
tabbedPane
protected JTabbedPane tabbedPane
- The tabbedPane that subclasses should ad their controller-specific tab to
For example see one of the standard controllers like the "StringFinder"
- See Also:
- StringFinder
rootURLField
protected JTextField rootURLField
maxDepthField
protected JTextField maxDepthField
maxNodeNumField
protected JTextField maxNodeNumField
startButton
protected JButton startButton
stopButton
protected JButton stopButton
info
protected JLabel info
progressBar
protected JProgressBar progressBar
maxThreadNumSlider
protected JSlider maxThreadNumSlider
onlySameHostBox
protected JCheckBox onlySameHostBox
enableStartTimeBox
protected JCheckBox enableStartTimeBox
startTimeLabel
protected JLabel startTimeLabel
startTimeField
protected JTextField startTimeField
enableMaxTimeBox
protected JCheckBox enableMaxTimeBox
currTimeLabel
protected JLabel currTimeLabel
maxTimeLabel
protected JLabel maxTimeLabel
maxTimeField
protected JTextField maxTimeField
nest
private Controller. NotifyEverySecondThread nest
userStarted
protected boolean userStarted
crawlerStarted
protected boolean crawlerStarted
secondsOver
protected int secondsOver
startHost
protected String startHost
Controller
public Controller()
- This constructor creates a new Crawler-object which is started by pressing the Start-Button
in the "General" tab. It also creates a new window which contains that "General" tab as well
as the "Advanced" tab.
A new NotifyEverySecond-thread is created and started. It will call this class' everySecond()
method once a second.
When deriving a new controller-class from this one, always call super() in the new class' constructor
- See Also:
- NotifyEverySecond, everySecond
actionPerformed
public void actionPerformed(ActionEvent e)
- Catches the ActionEvents when one of the buttons in the "General"-tab was pressed
always call super.actionEvent(e) in subclasses at the end of the subclass' method
stateChanged
public void stateChanged(ChangeEvent e)
- Catches the ChangeEvents when one of the Checkboxes int the "Advanced"-tab was clicked
saveCurrSettings
protected void saveCurrSettings()
- Saves the settings in the current Controller window.
Here the entries in all the components of the general and advanced tab are
stored to set\ctrl.dat
saveCurrSettings() is called by the actionPerformed-method.
Always call super.saveCurrSettings() in subclasses.
loadCurrSettings
protected void loadCurrSettings()
- Loads the settings for the current Controller window.
Here the entries in all the components of the general and advanced tab are
loaded and the fields on screen are set.
loadCurrSettings() is called by the actionPerformed-method.
Always call super.loadCurrSettings() in subclasses.
getCrawler
public Crawler getCrawler()
- This mehod can be used by the surrounding application for attaching visualizers to
the Crawler - since the crawler is being created by the controller.
- Returns:
- The Crawler-object that was created when this controller was created
everySecond
protected void everySecond()
- Called by the NotifyEverySecond-thread once a second. Here it is used to check
if the user had pressed the start-button. In this case, this method waits until
startTime (if enableStartTime is selected) and then calls startCrawler(). If enablemaxTime
is selected, this method calls stopCrawler() after the specified number of seconds.
startCrawler
public void startCrawler()
- Tells the Crawler the maximum number of allowed Reader-threads and starts the Crawler.
stopCrawler
public void stopCrawler()
- Stops the Crawler
willSonsBeLoaded
public boolean willSonsBeLoaded(HTMLNode n)
- Says if n's sons will be loaded in the future. If n is already at the max depth
it's sons won't be loaded.
This info is important for the Parsers, cuz' they don't need to do the
+"/index.html"-check for every son if it won't be loaded.
always call super.willSonsBeLoaded() in subclasses. Usually subclasses won't have
to override this method.
loadLink
public boolean loadLink(LoadableNode n)
- Subclasses should implement this mehtod. The Crawler always asks the Controller
if a link should be downloaded, using this method. Here it is made sure that the
URLType of the node is "normal", that the depth is < maxDepth and that there are
not more than maxNodeNum nodes read already. It is also checked that if the "Load
Links from same host only" Checkbox is selected, only links that have the same host
as the startURL will be loaded.
always call super.loadLink(n) in subclasses!
localFileName
public abstract String localFileName(LoadableNode n)
- Before the Crawler sends a node to the todo-pool for being downloaded, it asks
the controller, through this method, under what filename the downloaded data
should be stored locally.
addedANode
public void addedANode(URLNode n)
- When a new node is added to the tree, the Crawler calls this method to let
the Controller know. Here, this is used for counting the nodes in the tree,
so that if there are more than maxNodeNum nodes, the loadLink() method can
return false.
always call super.addedANode(n) in subclasses!
nodeLoaded
public void nodeLoaded(URLNode n)
- When the Crawler gets a node back from a Reader (= when the data has
been downloaded) the Crawler notifies the Controller, via this method.
Subclasses should use this method if they need to do any operations
on the local file (which has been downloaded by now).
always call super.nodeLoaded(n) in subclasses!
nodeDone
public abstract void nodeDone(URLNode n)
- Called by the Crawler when the node n is done (=loaded).
Here: abstract (=does nothing)
Note: always call the superclass' nodeDone method in subclasses!
crawlerDone
public void crawlerDone()
- Called by the Crawler when its work is done.
Subclasses should use this to clean up temporary files.
always call super.crawlerDone() in subclasses!
All Packages Class Hierarchy This Package Previous Next Index