KickJava   Java API By Example, From Geeks To Geeks.

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


1 package net.javacoding.jspider.mod.rule;
2
3 import net.javacoding.jspider.api.model.Decision;
4 import net.javacoding.jspider.api.model.Site;
5 import net.javacoding.jspider.core.SpiderContext;
6 import net.javacoding.jspider.core.rule.impl.BaseRuleImpl;
7 import net.javacoding.jspider.core.model.DecisionInternal;
8
9 import java.net.URL JavaDoc;
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, URL JavaDoc url) {
23         if (context.getBaseURL().getHost().equalsIgnoreCase(url.getHost())) {
24             return new DecisionInternal(Decision.RULE_ACCEPT, "url accepted");
25         } else {
26             return new DecisionInternal(Decision.RULE_IGNORE, "url ignored because it points to an external site");
27         }
28     }
29
30 }
31
32
Popular Tags