1 package net.javacoding.jspider.mod.plugin; 2 3 import net.javacoding.jspider.api.event.EventVisitor; 4 import net.javacoding.jspider.api.event.JSpiderEvent; 5 import net.javacoding.jspider.api.event.engine.*; 6 import net.javacoding.jspider.api.event.folder.FolderDiscoveredEvent; 7 import net.javacoding.jspider.api.event.folder.FolderRelatedEvent; 8 import net.javacoding.jspider.api.event.resource.*; 9 import net.javacoding.jspider.api.event.site.*; 10 import net.javacoding.jspider.api.model.*; 11 import net.javacoding.jspider.spi.Plugin; 12 13 16 public abstract class FlatOutputPlugin implements Plugin, EventVisitor { 17 18 public void visit(JSpiderEvent event) { 19 println (event); 20 } 21 22 public void visit(EngineRelatedEvent event) { 23 println (event); 24 } 25 26 public void visit(SpideringStartedEvent event) { 27 println("Module : " + getName ( ) ); 28 println("Version: " + getVersion( ) ); 29 println("Vendor : " + getVendor ( ) ); 30 println("Spidering Started, baseURL = " + event.getBaseURL()); 31 } 32 33 public final void initialize() { 34 setUp ( ); 35 } 36 37 public void shutdown() { 38 tearDown ( ); 39 } 40 41 public void visit(SpideringStoppedEvent event) { 42 println ("Spidering Stopped"); 43 } 44 45 public void visit(FolderRelatedEvent event) { 46 println (event); 47 } 48 49 public void visit(FolderDiscoveredEvent event) { 50 println (event); 51 } 52 53 public void visit(ResourceRelatedEvent event) { 54 println (event); 55 } 56 57 public void visit(EMailAddressDiscoveredEvent event) { 58 println(event); 59 } 60 61 public void visit(EMailAddressReferenceDiscoveredEvent event) { 62 println(event); 63 } 64 65 public void visit(MalformedURLFoundEvent event) { 66 println(event); 67 } 68 69 public void visit(MalformedBaseURLFoundEvent event) { 70 println(event); 71 } 72 73 public void visit(ResourceDiscoveredEvent event) { 74 println (event.getComment()); 75 } 76 77 public void visit(ResourceFetchedEvent event) { 78 FetchedResource resource = event.getResource(); 79 println ( resource.getHttpStatus() + " - " + resource.getURL() + " - " + resource.getMime() + " " + resource.getSize() + " " + resource.getTimeMs() + " ms"); 80 } 81 82 public void visit(ResourceFetchErrorEvent event) { 83 FetchErrorResource resource = event.getResource(); 84 println ( resource.getHttpStatus() + " - ERROR !!!" + resource.getURL()); 85 } 86 87 public void visit(ResourceForbiddenEvent event) { 88 println (event); 89 } 90 91 public void visit(ResourceParsedEvent event) { 92 println (event); 93 } 94 95 public void visit(ResourceIgnoredForFetchingEvent event) { 96 FetchIgnoredResource resource = event.getResource(); 97 println ( resource.getURL() + " - Ignored for fetching"); 98 } 99 100 public void visit(ResourceIgnoredForParsingEvent event) { 101 ParseIgnoredResource resource = event.getResource(); 102 println ( resource.getURL() + " - Ignored for parsing"); 103 } 104 105 public void visit(ResourceReferenceDiscoveredEvent event) { 106 111 } 112 113 public void visit(SiteRelatedEvent event) { 114 println ( event); 115 } 116 117 public void visit(SiteDiscoveredEvent event) { 118 println ( "site discovered : " + event.getSite().getURL() ); 119 } 120 121 public void visit(RobotsTXTMissingEvent event) { 122 println ( "robots.txt missing for site " + event.getSite()); 123 } 124 125 public void visit(RobotsTXTFetchedEvent event) { 126 println ( "robots.txt fetched from site " + event.getSite()); 127 } 128 129 public void visit(UserAgentObeyedEvent event) { 130 println ( event.getComment()); 131 } 132 133 public void notify(JSpiderEvent event) { 134 event.accept(this); 135 } 136 137 138 protected abstract void println ( Object object ); 139 140 protected void setUp ( ) { 141 } 142 143 protected void tearDown ( ) { 144 } 145 146 } 147 | Popular Tags |