added debug boolean and get choice method

This commit is contained in:
Sem van der Hoeven
2020-03-03 16:38:36 +01:00
parent 38b0524b0d
commit eb12a813b0
2 changed files with 22 additions and 4 deletions

View File

@@ -11,6 +11,7 @@ public class WebCrawler {
private int amountFound = 0;
private int successPages = 0;
private boolean shouldSaveHitLinks;
private boolean debug;
/**
* creates a new WebCrawler object with standard values
@@ -33,12 +34,17 @@ public class WebCrawler {
* @param shouldSaveHitLinks if the crawler should save the links that have one or more hits
*/
public WebCrawler(int maxPages, boolean shouldSaveHitLinks) {
this(maxPages,shouldSaveHitLinks,false);
}
public WebCrawler(int maxPages, boolean shouldSaveHitLinks, boolean debug) {
this.amountOfPages = maxPages;
this.shouldSaveHitLinks = shouldSaveHitLinks;
this.pagesVisited = new HashSet<>();
this.pagesPending = new LinkedList<>();
this.resultPages = new ArrayList<>();
this.urlHits = new HashMap<>();
this.debug = debug;
}
@@ -132,6 +138,14 @@ public class WebCrawler {
return amountFound;
}
public boolean usesDebug() {
return debug;
}
public void setDebug(boolean debug) {
this.debug = debug;
}
/**
* clears the crawler
*/