Reputation: 2423
I have a class that extends another class:
public class PDFCrawler extends WebCrawler
And I am overriding a method in my PDFCrawler class as follows:
@Override
public boolean shouldVisit(Page page, WebURL url) {...}
It gives me error on Eclipse. Java 8 is set for the project:
The method shouldVisit(Page, WebURL) of type PDFCrawler must override or implement supertype method.
However, in the same PDFCrawler class, when I am overriding a different method as follows, no error is shown:
@Override
public void visit(Page page) {...}
Both of these methods are from the super class named WebCrawler. The superclass methods are as follows:
public boolean shouldVisit(Page page, WebURL url) {
return true;
}
public void visit(Page page) {
// Do nothing by default
// Sub-classed should override this to add their custom functionality
}
The superclass is taken from Crawler4j project. As I cannot override the first method, the method in the superclass is always getting executed.
Any clue?
EDIT The import statements for my class PDFCrawler:
package com.example.ict;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
import java.util.regex.Pattern;
import com.google.common.io.Files;
import edu.uci.ics.crawler4j.crawler.Page;
import edu.uci.ics.crawler4j.crawler.WebCrawler;
import edu.uci.ics.crawler4j.url.WebURL;
Upvotes: 1
Views: 2092
Reputation: 695
I am guessing you're using the jar file from an older version of crawler4j. The signature of this method was different in the past and was changed without support for backward compatibility (unfortunately): https://github.com/yasserg/crawler4j/commit/c874761011d63e77977b914810eb44c054845233
Using the latest version of the jar should fix the issue.
Upvotes: 3
Reputation: 26981
Your import for WebURL
is wrong, this will work:
public boolean shouldVisit(Page page, edu.uci.ics.crawler4j.url.WebURL url) {...}
Page
as you used it in other @Override
, is OK, but not WebURL
, so better fix the imports!
Upvotes: 0
Reputation: 2937
PDFCrawler.shouldVisit method is using different parameter types. Most probably the types are from a different package.
Upvotes: 0