package hk.ust.comp4321.crawler;

import java.io.IOException;

import hk.ust.comp4321.database.IDGenerator;

/**
 * 
 * @author Alex Poon
 *
 */
public class Crawler
{

  // Constants and fields.
  // -------------------------------------------------------------------------
  
  private String url;
  private InvertedPageTable invertedPageTable;
  private IDGenerator wordIdGenerator = new IDGenerator();
  private IDGenerator pageIdGenerator = new IDGenerator();
  private const int TotalNumOfPage = 30;
  private int counter = 1;
  
  // Constructors.
  // -------------------------------------------------------------------------
  
  public Crawler(String url)
  {
    this.url = url;
    
    // Extract 30 pages
    try
      {
    	  while(counter <= TotalNumOfPage)
    	  {
    		  Extractor extractor = new Extractor(this.url, this.wordIdGenerator,
                                          this.pageIdGenerator);
    		  counter++;
    		  this.url = invertedPageTable.getPageInfo(i).getUrl();
    	  }
      }
    catch (IOException ex)
      {
        System.err.println(ex.toString());
      }
  }
}

@@ -472,13 +472,13 @@
 ate 
-const
+final
  int
@@ -517,19 +517,116 @@
 int 
-counter = 1
+InUseURL = 1;%0A  private Vector%3CString%3E v_link = new Vector%3CString%3E();%0A  private LinkBean lb = new LinkBean()
 ;%0A  
@@ -788,72 +788,492 @@
     
-%0A    // Extract 30 pages%0A    try%0A      %7B%0A    %09  while(counter
+//library http://downloads.sourceforge.net/htmlparser/htmlparser1_6_20060610.zip?modtime=1149940066&big_mirror=0 is needed%0A    v_link.addElement(url);%0A    do %0A    %7B%0A    %09lb.setURL(url);%0A    %09URL%5B%5D URL_array = lb.getLinks();%0A    %09for(int i=0; i%3CURL_array.length && v_link.size()%3CTotalNumOfPage; i++)%0A    %09%09v_link.addElement(URL_array%5Bi%5D.toString());%0A    %09InUseUrl++;%0A    %09// no exception handling if we can't crawle 30 pages%0A    %09url = v_link.get(UsingUrl);%0A   %7D while (v_link.size()
  %3C
-=
  Tot
@@ -1284,22 +1284,54 @@
 mOfPage)
+;
 %0A    
-%09
+// Extract 30 pages%0A    try%0A    
   %7B%0A    
@@ -1471,98 +1471,8 @@
 r);%0A
-    %09%09  counter++;%0A    %09%09  this.url = invertedPageTable.getPageInfo(i).getUrl();%0A    %09  %7D%0A
     

Update Crawler.java