1 11 package org.eclipse.help.search; 12 13 import java.net.URL ; 14 import java.util.ArrayList ; 15 import java.util.HashSet ; 16 import java.util.Set ; 17 18 import org.apache.lucene.document.Document; 19 import org.apache.lucene.document.Field; 20 import org.eclipse.core.runtime.FileLocator; 21 import org.eclipse.core.runtime.IStatus; 22 import org.eclipse.core.runtime.Path; 23 import org.eclipse.core.runtime.Platform; 24 import org.eclipse.help.internal.util.ResourceLocator; 25 import org.osgi.framework.Bundle; 26 27 55 public abstract class LuceneSearchParticipant { 56 57 private static final HashSet EMPTY_SET = new HashSet (); 58 59 private String id; 60 61 68 69 public final void init(String id) { 70 this.id = id; 71 } 72 73 78 public String getId() { 79 return id; 80 } 81 82 102 public abstract IStatus addDocument(ISearchIndex index, String pluginId, String name, URL url, String id, 103 Document doc); 104 105 114 public Set getAllDocuments(String locale) { 115 return EMPTY_SET; 116 } 117 118 124 125 public Set getContributingPlugins() { 126 return EMPTY_SET; 127 } 128 129 140 141 protected static String resolveVariables(String pluginId, String fileName, String locale) { 142 if (fileName.indexOf('$') == -1) 143 return fileName; 144 ArrayList prefix = ResourceLocator.getPathPrefix(locale); 145 Bundle bundle = Platform.getBundle(pluginId); 146 if (bundle == null) 147 return fileName; 148 URL url = ResourceLocator.find(bundle, new Path(fileName), prefix); 149 URL root = FileLocator.find(bundle, new Path(""), null); return url.toString().substring(root.toString().length()); 151 } 152 153 161 162 protected void addTitle(String title, Document doc) { 163 doc.add(new Field("title", title, Field.Store.NO, Field.Index.TOKENIZED)); doc.add(new Field("exact_title", title, Field.Store.NO, Field.Index.TOKENIZED)); doc.add(new Field("raw_title", title, Field.Store.YES, Field.Index.NO)); } 167 168 182 183 public boolean open(String id) { 184 return false; 185 } 186 187 192 public void clear() { 193 } 194 } 195 | Popular Tags |