1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.smartcrawler.filter;
28 import org.apache.log4j.Logger;
29 import org.smartcrawler.common.Context;
30 import org.smartcrawler.common.Link;
31 import org.smartcrawler.common.SCLogger;
32
33
34 /***
35 *
36 *
37 * @author <a href="mailto:pozzad@alice.it">Davide Pozza</a>
38 * @version <tt>$Revision: 1.6 $</tt>
39 */
40 public class DefaultLinkFilter implements PrecFilterLink {
41
42 private static Logger log = SCLogger.getLogger(DefaultLinkFilter.class);
43
44 /***
45 *
46 * @param link
47 * @return
48 */
49 public boolean isPermitted(Context conf, Link link) {
50 log.debug("isPermitted() BEGIN");
51 String hostname = conf.getInitialLink().getHost();
52 boolean res = true;
53 if (hostname != null) {
54 res = link.toString().indexOf(hostname) >= 0;
55 }
56 log.debug("Checking link: " + link.toString()
57 + " VS " + hostname + " res="+res);
58 log.debug("isPermitted() END");
59 return res;
60 }
61 }