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

搜索引擎

开发平台:

Java

  1. package net.javacoding.jspider.core.event.impl;
  2. import net.javacoding.jspider.core.SpiderContext;
  3. import net.javacoding.jspider.core.event.CoreEventVisitor;
  4. import net.javacoding.jspider.api.model.HTTPHeader;
  5. import java.net.URL;
  6. import java.net.URLConnection;
  7. /**
  8.  *
  9.  * $Id: URLSpideredErrorEvent.java,v 1.4 2003/04/01 19:44:37 vanrogu Exp $
  10.  *
  11.  * @author G黱ther Van Roey
  12.  */
  13. public class URLSpideredErrorEvent extends URLRelatedBaseEventImpl {
  14.     protected Exception error;
  15.     protected int httpStatus;
  16.     protected HTTPHeader[] headers;
  17.     public URLSpideredErrorEvent(SpiderContext context, URL url, int httpStatus, URLConnection urlConnection, HTTPHeader[] headers, Exception error) {
  18.         super(context, url);
  19.         this.error = error;
  20.         this.httpStatus = httpStatus;
  21.         this.headers = headers;
  22.     }
  23.     public String toString() {
  24.         return "url spidered : " + url + " ERROR : " + error.getClass() + ((httpStatus != 0) ? " (HTTP Status: " + httpStatus + ")" : "");
  25.     }
  26.     public void accept(URL url, CoreEventVisitor visitor) {
  27.         visitor.visit(url, this);
  28.     }
  29.     public HTTPHeader[] getHeaders ( ) {
  30.         return headers;
  31.     }
  32.     public int getHttpStatus() {
  33.         return httpStatus;
  34.     }
  35.     public Exception getException() {
  36.         return error;
  37.     }
  38. }