KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > javacoding > jspider > mod > rule > OnlyHttpProtocolRule


1 package net.javacoding.jspider.mod.rule;
2
3
4 import net.javacoding.jspider.api.model.Decision;
5 import net.javacoding.jspider.api.model.Site;
6 import net.javacoding.jspider.core.SpiderContext;
7 import net.javacoding.jspider.core.rule.impl.BaseRuleImpl;
8 import net.javacoding.jspider.core.model.DecisionInternal;
9
10 import java.net.URL JavaDoc;
11
12
13 /**
14  * Rule implementation that only accepts a resource URL if it points to a
15  * resource that is accessible over HTTP.
16  *
17  * $Id: OnlyHttpProtocolRule.java,v 1.1 2003/04/03 16:10:52 vanrogu Exp $
18  *
19  * @author Günther Van Roey
20  */

21 public class OnlyHttpProtocolRule extends BaseRuleImpl {
22
23     public Decision apply(SpiderContext context, Site currentSite, URL JavaDoc url) {
24         Decision decision = null;
25
26         String JavaDoc protocol = url.getProtocol();
27
28         if (protocol.equalsIgnoreCase("http")) {
29             decision = new DecisionInternal(Decision.RULE_ACCEPT);
30         } else {
31             decision = new DecisionInternal(Decision.RULE_IGNORE);
32         }
33
34         return decision;
35     }
36 }
37
Popular Tags