1 2 3 4 package net.nutch.indexer; 5 6 import java.util.HashMap ; 7 8 import org.apache.lucene.document.Document; 9 10 import net.nutch.plugin.*; 11 import net.nutch.parse.Parse; 12 import net.nutch.fetcher.FetcherOutput; 13 14 15 public class IndexingFilters { 16 17 private static final IndexingFilter[] CACHE; 18 static { 19 try { 20 ExtensionPoint point = PluginRepository.getInstance() 21 .getExtensionPoint(IndexingFilter.X_POINT_ID); 22 if (point == null) 23 throw new RuntimeException (IndexingFilter.X_POINT_ID+" not found."); 24 Extension[] extensions = point.getExtentens(); 25 HashMap filterMap = new HashMap (); 26 for (int i = 0; i < extensions.length; i++) { 27 Extension extension = extensions[i]; 28 IndexingFilter filter = (IndexingFilter)extension.getExtensionInstance(); 29 if (!filterMap.containsKey(filter.getClass().getName())) { 30 filterMap.put(filter.getClass().getName(), filter); 31 } 32 } 33 CACHE = (IndexingFilter[])filterMap.values().toArray(new IndexingFilter[0]); 34 } catch (PluginRuntimeException e) { 35 throw new RuntimeException (e); 36 } 37 } 38 39 private IndexingFilters() {} 41 42 public static Document filter(Document doc, Parse parse, FetcherOutput fo) 43 throws IndexingException { 44 45 for (int i = 0; i < CACHE.length; i++) { 46 doc = CACHE[i].filter(doc, parse, fo); 47 } 48 49 return doc; 50 } 51 } 52 | Popular Tags |