01: package net.javacoding.jspider.mod.rule;
02:
03: import net.javacoding.jspider.api.model.Decision;
04: import net.javacoding.jspider.api.model.Site;
05: import net.javacoding.jspider.core.SpiderContext;
06: import net.javacoding.jspider.core.rule.impl.BaseRuleImpl;
07: import net.javacoding.jspider.core.model.DecisionInternal;
08:
09: import java.net.URL;
10:
11: /**
12: * Rule implementation that only decides to accept a URL in case the resource
13: * to which this url points lies in the site of the original starting point
14: * of spidering.
15: *
16: * $Id: BaseSiteOnlyRule.java,v 1.1 2003/04/03 16:10:48 vanrogu Exp $
17: *
18: * @author Günther Van Roey.
19: */
20: public class BaseSiteOnlyRule extends BaseRuleImpl {
21:
22: public Decision apply(SpiderContext context, Site currentSite,
23: URL url) {
24: if (context.getBaseURL().getHost().equalsIgnoreCase(
25: url.getHost())) {
26: return new DecisionInternal(Decision.RULE_ACCEPT,
27: "url accepted");
28: } else {
29: return new DecisionInternal(Decision.RULE_IGNORE,
30: "url ignored because it points to an external site");
31: }
32: }
33:
34: }
|