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 accepts a resource URL if it points to a
13: * resource that is accessible over HTTP.
14: *
15: * $Id: OnlyHttpProtocolRule.java,v 1.1 2003/04/03 16:10:52 vanrogu Exp $
16: *
17: * @author Günther Van Roey
18: */
19: public class OnlyHttpProtocolRule extends BaseRuleImpl {
20:
21: public Decision apply(SpiderContext context, Site currentSite,
22: URL url) {
23: Decision decision = null;
24:
25: String protocol = url.getProtocol();
26:
27: if (protocol.equalsIgnoreCase("http")) {
28: decision = new DecisionInternal(Decision.RULE_ACCEPT);
29: } else {
30: decision = new DecisionInternal(Decision.RULE_IGNORE);
31: }
32:
33: return decision;
34: }
35: }
|