diff options
Diffstat (limited to 'org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java')
-rw-r--r-- | org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java index 85a6137ae..037ce28dc 100644 --- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java +++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -60,8 +60,10 @@ import org.eclipse.help.internal.protocols.HelpURLStreamHandler; import org.eclipse.help.internal.toc.TocFileProvider; import org.eclipse.help.internal.toc.TocManager; import org.eclipse.help.internal.util.ResourceLocator; +import org.eclipse.help.search.IHelpSearchIndex; +import org.eclipse.help.search.ISearchDocument; import org.eclipse.help.search.ISearchIndex; -import org.eclipse.help.search.LuceneSearchParticipant; +import org.eclipse.help.search.SearchParticipant; import org.osgi.framework.Bundle; import org.osgi.framework.Constants; import org.osgi.framework.Version; @@ -69,7 +71,7 @@ import org.osgi.framework.Version; /** * Text search index. Documents added to this index can than be searched against a search query. */ -public class SearchIndex implements ISearchIndex { +public class SearchIndex implements ISearchIndex, IHelpSearchIndex { private IndexReader ir; @@ -192,8 +194,8 @@ public class SearchIndex implements ISearchIndex { if (relativePath != null) { doc.add(new Field(FIELD_INDEX_ID, relativePath, Field.Store.YES, Field.Index.UN_TOKENIZED)); } - // NEW: check for the explicit search participant. - LuceneSearchParticipant participant = null; + // check for the explicit search participant. + SearchParticipant participant = null; HelpURLConnection urlc = new HelpURLConnection(url); String id = urlc.getValue("id"); //$NON-NLS-1$ String pid = urlc.getValue("participantId"); //$NON-NLS-1$ @@ -203,7 +205,7 @@ public class SearchIndex implements ISearchIndex { if (participant == null) participant = BaseHelpSystem.getLocalSearchManager().getParticipant(pluginId, name); if (participant != null) { - IStatus status = participant.addDocument(this, pluginId, name, url, id, doc); + IStatus status = participant.addDocument(this, pluginId, name, url, id, new LuceneSearchDocument(doc)); if (status.getSeverity() == IStatus.OK) { String filters = doc.get("filters"); //$NON-NLS-1$ indexedDocs.put(name, filters != null ? filters : "0"); //$NON-NLS-1$ @@ -1045,11 +1047,11 @@ public class SearchIndex implements ISearchIndex { public IStatus addDocument(String pluginId, String name, URL url, String id, Document doc) { // try a registered participant for the file format - LuceneSearchParticipant participant = BaseHelpSystem.getLocalSearchManager() + SearchParticipant participant = BaseHelpSystem.getLocalSearchManager() .getParticipant(pluginId, name); if (participant != null) { try { - return participant.addDocument(this, pluginId, name, url, id, doc); + return participant.addDocument(this, pluginId, name, url, id, new LuceneSearchDocument(doc)); } catch (Throwable t) { return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR, @@ -1060,4 +1062,10 @@ public class SearchIndex implements ISearchIndex { // default to html return htmlSearchParticipant.addDocument(this, pluginId, name, url, id, doc); } + + public IStatus addSearchableDocument(String pluginId, String name, URL url, String id, ISearchDocument doc) { + // In the help system the only class that implements ISearchDocument is LuceneSearchDocument + LuceneSearchDocument luceneDoc = (LuceneSearchDocument)doc; + return addDocument(pluginId, name, url, id, luceneDoc.getDocument()); + } } |