1 package net.javacoding.jspider.core.event.impl; 2 3 4 import net.javacoding.jspider.api.model.HTTPHeader; 5 import net.javacoding.jspider.core.SpiderContext; 6 import net.javacoding.jspider.core.event.CoreEventVisitor; 7 8 import java.net.URL ; 9 import java.net.URLConnection ; 10 11 12 18 public class URLSpideredOkEvent extends URLRelatedBaseEventImpl { 19 20 protected String mimeType; 21 protected int timeMs; 22 protected int size; 23 protected byte[] bytes; 24 protected int httpStatus; 25 protected URLConnection urlConnection; 26 protected HTTPHeader[] headers; 27 28 public URLSpideredOkEvent(SpiderContext context, URL url, int httpStatus, URLConnection urlConnection, String mimeType, int timeMs, int size, byte[] bytes, HTTPHeader[] headers) { 29 super(context, url); 30 this.mimeType = mimeType; 31 this.timeMs = timeMs; 32 this.size = size; 33 this.bytes = bytes; 34 this.httpStatus = httpStatus; 35 this.urlConnection = urlConnection; 36 this.headers = headers; 37 } 38 39 public byte[] getBytes() { 40 return bytes; 41 } 42 43 public String toString() { 44 return "url spidered : " + url + " (" + httpStatus + "," + mimeType + "," + timeMs + " ms," + size + " bytes )"; 45 } 46 47 public void accept(URL url, CoreEventVisitor visitor) { 48 visitor.visit(url, this); 49 } 50 51 public URLConnection getURLConnection() { 52 return urlConnection; 53 } 54 55 public int getSize() { 56 return size; 57 } 58 59 public String getMimeType() { 60 return mimeType; 61 } 62 63 public int getHttpStatus() { 64 return httpStatus; 65 } 66 67 public int getTimeMs() { 68 return timeMs; 69 } 70 71 public HTTPHeader[] getHeaders ( ) { 72 return headers; 73 } 74 } 75 | Popular Tags |