BaseSiteOnlyRule.java
上传用户:qing5858
上传日期:2015-10-27
资源大小:6056k
文件大小:1k
源码类别:

搜索引擎

开发平台:

Java

  1. package net.javacoding.jspider.mod.rule;
  2. import net.javacoding.jspider.api.model.Decision;
  3. import net.javacoding.jspider.api.model.Site;
  4. import net.javacoding.jspider.core.SpiderContext;
  5. import net.javacoding.jspider.core.rule.impl.BaseRuleImpl;
  6. import net.javacoding.jspider.core.model.DecisionInternal;
  7. import java.net.URL;
  8. /**
  9.  * Rule implementation that only decides to accept a URL in case the resource
  10.  * to which this url points lies in the site of the original starting point
  11.  * of spidering.
  12.  *
  13.  * $Id: BaseSiteOnlyRule.java,v 1.1 2003/04/03 16:10:48 vanrogu Exp $
  14.  *
  15.  * @author G黱ther Van Roey.
  16.  */
  17. public class BaseSiteOnlyRule extends BaseRuleImpl {
  18.     public Decision apply(SpiderContext context, Site currentSite, URL url) {
  19.         if (context.getBaseURL().getHost().equalsIgnoreCase(url.getHost())) {
  20.             return new DecisionInternal(Decision.RULE_ACCEPT, "url accepted");
  21.         } else {
  22.             return new DecisionInternal(Decision.RULE_IGNORE, "url ignored because it points to an external site");
  23.         }
  24.     }
  25. }