ISSearch
Class ISCrawler

java.lang.Object
  extended byISSearch.ISCrawler
All Implemented Interfaces:
ISCrawlerInterface, Runnable

public class ISCrawler
extends Object
implements ISCrawlerInterface

The Crawler class of the Web search engine. This class is used to start and stop the Crawler, to reset the engine and to control crawling parameters.

See Also:
Runnable, Thread, InetAddress, URL, HttpURLConnection, InputStreamReader, BufferedReader, Exception

Field Summary
 
Fields inherited from interface ISSearch.ISCrawlerInterface
RUNNING, STOPPED
 
Constructor Summary
ISCrawler()
          Creates a new instance of ISCrawler
 
Method Summary
 void addLink(URL link)
          Adds a new link to the URL queue, if the link is not yet visited.
 URL getBest()
          Returns the best candidate to be visited next.
 int getCrawlingDepth()
          Returns the current maximum allowed crawling depth.
 ISDocumentInterface getCurrentDocument()
          Returns the last document visited by the Crawler.
 URL getCurrentURL()
          Returns the last URL visited by the Crawler.
 int getMaxQueueSize()
          Returns the maximum allowed size of the URL Queue
 int getQueueSize()
          Returns the current size of the URL queue
 int getState()
          Returns the current state of the crawler.
 boolean isVisited(URL doc)
          Checks if the URL of the given document is already visited by the crawler.
 void reset()
          Resets the crawler.
 void run()
          When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.
 void setCrawlingDepth(int depth)
          Sets the maximum allowed crawling depth.
 void setQueueMaxSize(int m)
          Set the maximum allowed size of the URL queue
 void start()
          Starts the thread of the crawler and changes the engine state to RUNNING
 void stop()
          Stops the crawler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ISCrawler

public ISCrawler()
Creates a new instance of ISCrawler

Method Detail

addLink

public void addLink(URL link)
Adds a new link to the URL queue, if the link is not yet visited.

Specified by:
addLink in interface ISCrawlerInterface
Parameters:
link - The URL link representation of the new target

getBest

public URL getBest()
Returns the best candidate to be visited next. The result must have the highest priority (in the sense of the selected ordering strategy) under all available links.

Specified by:
getBest in interface ISCrawlerInterface
Returns:
The best target to be visited by the Crawler next, null if the queue is empty.

getCrawlingDepth

public int getCrawlingDepth()
Returns the current maximum allowed crawling depth.

Specified by:
getCrawlingDepth in interface ISCrawlerInterface
Returns:
The current allowed craling depth.

getCurrentDocument

public ISDocumentInterface getCurrentDocument()
Returns the last document visited by the Crawler.

Specified by:
getCurrentDocument in interface ISCrawlerInterface
Returns:
The last visited document as object that implements ISDocumentInterface (and contains all extracted links, words and their stems); null if no documents were crawled yet.

getCurrentURL

public URL getCurrentURL()
Returns the last URL visited by the Crawler.

Specified by:
getCurrentURL in interface ISCrawlerInterface
Returns:
The last visited URL; null if no links were crawled yet.

getMaxQueueSize

public int getMaxQueueSize()
Returns the maximum allowed size of the URL Queue

Specified by:
getMaxQueueSize in interface ISCrawlerInterface
Returns:
The max allowed Queue size

getQueueSize

public int getQueueSize()
Returns the current size of the URL queue

Specified by:
getQueueSize in interface ISCrawlerInterface
Returns:
The current size of the URL queue.

getState

public int getState()
Returns the current state of the crawler. Possible states are RUNNING and STOPPED.

Specified by:
getState in interface ISCrawlerInterface
Returns:
The current state of the crawler, RUNNING oder STOPPED

isVisited

public boolean isVisited(URL doc)
Checks if the URL of the given document is already visited by the crawler.

Specified by:
isVisited in interface ISCrawlerInterface
Returns:
true if the engine was able to recognize the given URL as already visited, false.

setCrawlingDepth

public void setCrawlingDepth(int depth)
Sets the maximum allowed crawling depth.

Specified by:
setCrawlingDepth in interface ISCrawlerInterface
Parameters:
depth - The maximum allowed craling depth.

setQueueMaxSize

public void setQueueMaxSize(int m)
Set the maximum allowed size of the URL queue

Specified by:
setQueueMaxSize in interface ISCrawlerInterface
Parameters:
m - The maximum allowed Queue size

start

public void start()
Starts the thread of the crawler and changes the engine state to RUNNING

Specified by:
start in interface ISCrawlerInterface

stop

public void stop()
Stops the crawler. This method stops crawling and sets the engine status to STOPPED.

Specified by:
stop in interface ISCrawlerInterface

reset

public void reset()
Resets the crawler. This method stops the crawling, resets the URL queue, and the list of visited links. Finally, it sets the crawler status to STOPPED,

Specified by:
reset in interface ISCrawlerInterface

run

public void run()
Description copied from interface: Runnable
When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

The general contract of the method run is that it may take any action whatsoever.

Specified by:
run in interface Runnable
See Also:
Thread.run()