1 32 33 package websphinx; 34 35 40 public class LinkEvent 41 { 42 Crawler crawler; 43 int id; 44 Link link; 45 Throwable exception; 46 47 51 public static final int NONE = 0; 52 53 56 public static final int SKIPPED = 1; 57 58 61 public static final int ALREADY_VISITED = 2; 62 63 66 public static final int TOO_DEEP = 3; 67 68 71 public static final int QUEUED = 4; 72 73 76 public static final int RETRIEVING = 5; 77 78 82 public static final int ERROR = 6; 83 84 87 public static final int DOWNLOADED = 7; 88 89 92 public static final int VISITED = 8; 93 94 97 public static final String [] eventName = { 98 "none", 99 "skipped", 100 "already visited", 101 "too deep", 102 "queued", 103 "retrieving", 104 "error", 105 "downloaded", 106 "visited" 107 }; 108 109 115 public LinkEvent (Crawler crawler, int id, Link link) { 116 this.crawler = crawler; 117 this.id = id; 118 this.link = link; 119 } 120 121 128 public LinkEvent (Crawler crawler, int id, Link link, Throwable exception) { 129 this.crawler = crawler; 130 this.id = id; 131 this.link = link; 132 this.exception = exception; 133 } 134 135 139 public Crawler getCrawler () { 140 return crawler; 141 } 142 143 147 public int getID () { return id; } 148 149 153 public String getName () { return eventName[id]; } 154 155 159 public Link getLink () { return link; } 160 161 165 public Throwable getException () { return exception; } 166 167 170 public String toString () { 171 String result; 172 if (id == ERROR) 173 result = exception.toString(); 174 else 175 result = eventName[id]; 176 result += " " + link.toDescription (); 177 return result; 178 } 179 } 180
| Popular Tags
|