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

搜索引擎

开发平台:

Java

  1. package net.javacoding.jspider.core.rule.impl;
  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.model.DecisionInternal;
  6. import java.net.URL;
  7. /**
  8.  * $Id: BaseURLOnlyRule.java,v 1.2 2003/03/27 17:44:07 vanrogu Exp $
  9.  *
  10.  * @author G黱ther Van Roey.
  11.  */
  12. public class BaseURLOnlyRule extends BaseRuleImpl {
  13.     public Decision apply(SpiderContext context, Site currentSite, URL url) {
  14.         boolean equals = context.getBaseURL().equals(url);
  15.         if (equals) {
  16.             return new DecisionInternal(Decision.RULE_ACCEPT, "url accepted");
  17.         } else {
  18.             return new DecisionInternal(Decision.RULE_IGNORE, "url ignored because it is not the base url");
  19.         }
  20.     }
  21. }