BaseURLOnlyRule.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.  * $Id: BaseURLOnlyRule.java,v 1.1 2003/04/03 16:10:49 vanrogu Exp $
  10.  *
  11.  * @author G黱ther Van Roey.
  12.  */
  13. public class BaseURLOnlyRule extends BaseRuleImpl {
  14.     public Decision apply(SpiderContext context, Site currentSite, URL url) {
  15.         boolean equals = context.getBaseURL().equals(url);
  16.         if (equals) {
  17.             return new DecisionInternal(Decision.RULE_ACCEPT, "url accepted");
  18.         } else {
  19.             return new DecisionInternal(Decision.RULE_IGNORE, "url ignored because it is not the base url");
  20.         }
  21.     }
  22. }