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 package org.archive.crawler.deciderules;
26
27 import org.archive.crawler.datamodel.CandidateURI;
28
29
30
31 /***
32 * Rule applies the configured decision for any URI which has a 'via'
33 * (essentially, any URI that was a seed or some kinds of mid-crawl adds).
34 *
35 * @author gojomo
36 */
37 public class HasViaDecideRule extends PredicatedDecideRule {
38
39 private static final long serialVersionUID = 1670292311303097735L;
40
41 /***
42 * Usual constructor.
43 * @param name Name of this DecideRule.
44 */
45 public HasViaDecideRule(String name) {
46 super(name);
47 setDescription("HasViaDecideRule. Applies configured decision " +
48 "to any URI that has a 'via'.");
49 }
50
51 /***
52 * Evaluate whether given object is over the threshold number of
53 * hops.
54 *
55 * @param object
56 * @return true if the mx-hops is exceeded
57 */
58 protected boolean evaluate(Object object) {
59 try {
60 CandidateURI curi = (CandidateURI)object;
61 return curi.getVia() != null;
62 } catch (ClassCastException e) {
63
64 return false;
65 }
66 }
67 }