cs132.webSpider
Class WebPage

java.lang.Object
  extended by cs132.webSpider.WebPage

public class WebPage
extends java.lang.Object

This class provides an abstraction for a web page in a web crawler. For each web page, we record the URL of the web page, whether or not the crawled has visited the web page, and a set of hypertext links from the web page to other web pages.


Constructor Summary
WebPage(java.net.URL u)
          Create a new WebPage
 
Method Summary
 void addLink(WebPage w)
          Adds a link to the WebPage
 java.util.Set<WebPage> getLinks()
          Returns a set of Webpages linked to by this web page
 java.net.URL getURL()
          Gets the URL associated with this web page
 boolean isVisited()
          Reports whether the web page has been visited.
 java.lang.String toString()
           
 void visit()
          Make the web page as visited
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebPage

public WebPage(java.net.URL u)
Create a new WebPage

Parameters:
u - - the URL of this WebPage
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getURL

public java.net.URL getURL()
Gets the URL associated with this web page

Returns:
URL associated with this web page

isVisited

public boolean isVisited()
Reports whether the web page has been visited.

Returns:
true if the web page has been visited

visit

public void visit()
Make the web page as visited

Throws:
java.lang.IllegalStateException - if this web page has already been marked as visited

addLink

public void addLink(WebPage w)
Adds a link to the WebPage

Parameters:
w - - WebPage that this WebPage links to
Throws:
java.lang.IllegalStateException - - if the page referenced by this is not already marked as visited (we don't care whether or not w has already been visited)

getLinks

public java.util.Set<WebPage> getLinks()
Returns a set of Webpages linked to by this web page

Returns:
a set of WebPages linked to by this web page


Web Accessibility