Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.help.base/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.help.base/plugin.xml1
-rw-r--r--org.eclipse.help.base/schema/searchParticipant.exsd194
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java10
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java4
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java85
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java55
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchParticipantAdapter.java68
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java24
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelp.java2
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/search/IHelpSearchIndex.java55
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/search/ISearchDocument.java53
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipant.java190
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java385
-rw-r--r--org.eclipse.ua.tests/data/help/search/participant_xml_1.xml22
-rw-r--r--org.eclipse.ua.tests/data/help/search/participant_xml_2.xml23
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java3
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipant.java48
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipantXML.java64
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java70
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java70
-rw-r--r--org.eclipse.ua.tests/plugin.xml17
22 files changed, 38 insertions, 1407 deletions
diff --git a/org.eclipse.help.base/META-INF/MANIFEST.MF b/org.eclipse.help.base/META-INF/MANIFEST.MF
index e715cd206..1c3c6f3c5 100644
--- a/org.eclipse.help.base/META-INF/MANIFEST.MF
+++ b/org.eclipse.help.base/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %help_base_plugin_name
Bundle-SymbolicName: org.eclipse.help.base; singleton:=true
-Bundle-Version: 3.5.0.qualifier
+Bundle-Version: 3.4.100.qualifier
Bundle-Activator: org.eclipse.help.internal.base.HelpBasePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/org.eclipse.help.base/plugin.xml b/org.eclipse.help.base/plugin.xml
index f98b2e86d..d1cf74835 100644
--- a/org.eclipse.help.base/plugin.xml
+++ b/org.eclipse.help.base/plugin.xml
@@ -18,7 +18,6 @@
<extension-point id="activitySupport" name="%activity_extension_point_name" schema="schema/activitySupport.exsd"/>
<extension-point id="luceneSearchParticipants" name="%search_participant_extension_point_name" schema="schema/luceneSearchParticipants.exsd"/>
<extension-point id="server" name="%server_extension_point_name" schema="schema/server.exsd"/>
- <extension-point id="searchParticipant" name="Help Search Participant" schema="schema/searchParticipant.exsd"/>
<!-- Stand-alone infocenter application -->
<extension
diff --git a/org.eclipse.help.base/schema/searchParticipant.exsd b/org.eclipse.help.base/schema/searchParticipant.exsd
deleted file mode 100644
index f69de320a..000000000
--- a/org.eclipse.help.base/schema/searchParticipant.exsd
+++ /dev/null
@@ -1,194 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.help.base" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.help.base" id="searchParticipant" name="Help Search Participant"/>
- </appInfo>
- <documentation>
- This extension point should be used to add document content to the search index. There are two cases were you would want to add a search participant:
-&lt;ol&gt;
-&lt;li&gt;
-To index documents registered with the help system&apos;s TOC that are not of the HTML format (e.g. XML). In this case, the participant must declare file extensions it can handle. It will be called to index each matching document. In this case, the participant has the plug-in scope.
-&lt;/li&gt;
-&lt;li&gt;
-To index documents outside of the help system&apos;s TOC. In this case, the participant will be given a chance to index all the documents it knows about at once. In addition, the participant will be delegated the task of opening the search result because the help system will not know how to open the documents outside the TOC. In this case, the participant has global scope.
-&lt;/li&gt;
-&lt;/ol&gt;
-&lt;p&gt;
-Search participants are associated with the plug-in the extension appears in. In order to reuse the participant in other plug-ins, &lt;code&gt;binding&lt;/code&gt; should be used to reference them. This strategy prevents a plug-in from imposing its participant on the entire product for the file extensions it was registered with. By adding an explicit reference, the plug-in declares that it allows the referenced search participant to handle indexing of documents with those extensions. For documents that are not part of the TOC, there is no such danger. For this reason, they are global and &lt;code&gt;binding&lt;/code&gt; should not be used.
-&lt;/p&gt;
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <choice minOccurs="1" maxOccurs="unbounded">
- <element ref="searchParticipant"/>
- <element ref="binding"/>
- </choice>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="searchParticipant">
- <annotation>
- <appInfo>
- <meta.element labelAttribute="id" icon="icon"/>
- </appInfo>
- </annotation>
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- a unique identifier of this search participant
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional translatable name that will be used to represent the participant as a category of documents that can be included in the search. The name is not required when the participant is used for documents in the TOC (i.e. when &lt;code&gt;extensions&lt;/code&gt; attribute is set).
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="icon" type="string">
- <annotation>
- <documentation>
- an optional icon to be used to render search hits from the documents indexed by this participant. The icon will be used for the documents outside of the help&apos;s TOC to indicate that opening the search hit may result in an action different from showing the regular help document. Consequently, icon is not required when the participant is used for documents in the TOC (i.e. when &lt;code&gt;extensions&lt;/code&gt; attribute is set).
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="participant" type="string">
- <annotation>
- <documentation>
- The implementation class for the help search participant. This class must implement the &lt;samp&gt;org.eclipse.help.search.SearchParticipant&lt;/samp&gt; interface. This attribute may be omitted, and the nested &lt;samp&gt;participant&lt;/samp&gt; element may be provided instead.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.help.IHelpSerchParticipant"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="extensions" type="string">
- <annotation>
- <documentation>
- an optional field containing the list of file types handled by the search participant. This is a string containing comma separate file extensions (e.g. &quot;abc, xyz&quot;). This attribute should be used when files are made explicitly known to the help system in the &lt;code&gt;org.eclipse.help.toc&lt;/code&gt; extension point. The absence of this attribute is an indication that the participant will index all the documents it is responsible for by itself.
-&lt;p&gt;Note also that participants that are registered for known documents have plug-in scope. If you want a participant to apply to documents in another plug-in, you must use the &lt;code&gt;binding&lt;/code&gt; element to extend the scope. In contrast, participants that do not specify this attribute have global scope.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="headless" type="boolean" use="default" value="false">
- <annotation>
- <documentation>
- specifies whether or not this search participant should be used when running the help system outside an eclipse workbench, i.e. it is running in either standalone or infocenter mode. The default value is &lt;code&gt;false&lt;/code&gt;.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="binding">
- <complexType>
- <attribute name="participantId" type="string">
- <annotation>
- <documentation>
- a reference to the search participant declared elsewhere using &lt;code&gt;searchParticipant&lt;/code&gt; element. Binding can be used to reuse search participants in plug-ins without violating the top-down policy. Binding is only needed for indexing documents that are part of the TOC. Otherwise, participant has global scope.
- </documentation>
- <appInfo>
- <meta.attribute kind="identifier" basedOn="org.eclipse.help.base.luceneSearchParticipants/searchParticipant/@id"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 3.5
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- The following is a sample usage of the extension point:
-
-&lt;p&gt;
-&lt;pre&gt;
- &lt;extension point=&quot;org.eclipse.help.base.luceneSearchParticipant&quot;&gt;
- &lt;searchParticipant id=&quot;org.eclipse.myGlobalParticipant&quot;
- name=&quot;Global Participant&quot;
- icon=&quot;icons/mydoc.gif&quot;
- participant=&quot;org.eclipse.myPlugin.myPackage.MyGlobalParticipant&quot;
- headless=&quot;true&quot;/&gt;
- &lt;searchParticipant id=&quot;org.eclipse.myXYZParticipant&quot;
- extensions=&quot;xyz&quot;
- participant=&quot;org.eclipse.myPlugin.myPackage.MyXYZParticipant&quot;/&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- The supplied search participant class must extend the &lt;samp&gt;org.eclipse.help.search.SearchParticipant&lt;/samp&gt; abstract class.
- </documentation>
- </annotation>
-
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2010 IBM Corporation and others.&lt;br&gt;
-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 &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java
index 32a7d9d9c..729dc5f6e 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java
@@ -22,10 +22,8 @@ import org.eclipse.core.runtime.content.IContentDescriber;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.base.HelpBasePlugin;
import org.eclipse.help.internal.xhtml.XHTMLContentDescriber;
-import org.eclipse.help.search.IHelpSearchIndex;
import org.eclipse.help.search.ISearchIndex;
import org.eclipse.help.search.LuceneSearchParticipant;
-import org.eclipse.help.search.SearchParticipant;
public class HTMLSearchParticipant extends LuceneSearchParticipant {
@@ -46,11 +44,11 @@ public class HTMLSearchParticipant extends LuceneSearchParticipant {
// if it's XHTML, forward it on to the proper search participant
if (isXHTML(pluginId, url)) {
LocalSearchManager manager = BaseHelpSystem.getLocalSearchManager();
- SearchParticipant participant = manager.getParticipant(HELP_BASE_XHTML);
+ LuceneSearchParticipant participant = manager.getParticipant(HELP_BASE_XHTML);
if (participant == null) {
participant = getXhtmlParticipant();
}
- return participant.addDocument((IHelpSearchIndex) index, pluginId, name, url, id, new LuceneSearchDocument(doc));
+ return participant.addDocument(index, pluginId, name, url, id, doc);
}
// otherwise, treat it as HTML
else {
@@ -90,11 +88,11 @@ public class HTMLSearchParticipant extends LuceneSearchParticipant {
}
}
- private SearchParticipant getXhtmlParticipant() {
+ private XHTMLSearchParticipant getXhtmlParticipant() {
if (xhtmlParticipant == null) {
xhtmlParticipant = new XHTMLSearchParticipant();
}
- return new LuceneSearchParticipantAdapter(xhtmlParticipant);
+ return xhtmlParticipant;
}
/**
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java
index de3dea14a..55a2765a2 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java
@@ -39,7 +39,7 @@ import org.eclipse.help.internal.base.util.HelpProperties;
import org.eclipse.help.internal.protocols.HelpURLConnection;
import org.eclipse.help.internal.toc.Toc;
import org.eclipse.help.internal.toc.TocFileProvider;
-import org.eclipse.help.search.SearchParticipant;
+import org.eclipse.help.search.LuceneSearchParticipant;
/**
* Indexing Operation represents a long operation, which performs indexing of
@@ -372,7 +372,7 @@ class IndexingOperation {
}
}
//Add documents from global search participants
- SearchParticipant[] participants = BaseHelpSystem.getLocalSearchManager().getGlobalParticipants();
+ LuceneSearchParticipant[] participants = BaseHelpSystem.getLocalSearchManager().getGlobalParticipants();
for (int j=0; j<participants.length; j++) {
String participantId;
try {
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java
index 1a09c8551..438c9fb47 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java
@@ -39,7 +39,6 @@ import org.eclipse.help.internal.base.HelpBasePlugin;
import org.eclipse.help.internal.search.IndexingOperation.IndexingException;
import org.eclipse.help.internal.util.URLCoder;
import org.eclipse.help.search.LuceneSearchParticipant;
-import org.eclipse.help.search.SearchParticipant;
import org.osgi.framework.Bundle;
/*
@@ -47,8 +46,7 @@ import org.osgi.framework.Bundle;
*/
public class LocalSearchManager {
- private static final String LUCENE_SEARCH_PARTICIPANT_XP_FULLNAME = "org.eclipse.help.base.luceneSearchParticipants"; //$NON-NLS-1$
- private static final String SEARCH_PARTICIPANT_XP_FULLNAME = "org.eclipse.help.base.searchParticipant"; //$NON-NLS-1$
+ private static final String SEARCH_PARTICIPANT_XP_FULLNAME = "org.eclipse.help.base.luceneSearchParticipants"; //$NON-NLS-1$
private static final String SEARCH_PARTICIPANT_XP_NAME = "searchParticipant"; //$NON-NLS-1$
private static final String BINDING_XP_NAME = "binding"; //$NON-NLS-1$
private static final Object PARTICIPANTS_NOT_FOUND = new Object();
@@ -61,7 +59,7 @@ public class LocalSearchManager {
private static class ParticipantDescriptor implements IHelpResource {
private IConfigurationElement element;
- private SearchParticipant participant;
+ private LuceneSearchParticipant participant;
public ParticipantDescriptor(IConfigurationElement element) {
this.element = element;
@@ -88,16 +86,12 @@ public class LocalSearchManager {
return this;
}
- public SearchParticipant getParticipant() {
+ public LuceneSearchParticipant getParticipant() {
if (participant == null) {
try {
Object obj = element.createExecutableExtension("participant"); //$NON-NLS-1$
- if (obj instanceof SearchParticipant) {
- participant = (SearchParticipant)obj;
- participant.init(getId());
- } else if (obj instanceof LuceneSearchParticipant) {
- LuceneSearchParticipant luceneParticipant = (LuceneSearchParticipant) obj;
- participant = new LuceneSearchParticipantAdapter(luceneParticipant);
+ if (obj instanceof LuceneSearchParticipant) {
+ participant = (LuceneSearchParticipant) obj;
participant.init(getId());
}
} catch (Throwable t) {
@@ -265,7 +259,7 @@ public class LocalSearchManager {
return pluginId;
}
- public SearchParticipant getGlobalParticipant(String participantId) {
+ public LuceneSearchParticipant getGlobalParticipant(String participantId) {
ParticipantDescriptor desc = getGlobalParticipantDescriptor(participantId);
return desc != null ? desc.getParticipant() : null;
}
@@ -300,7 +294,7 @@ public class LocalSearchManager {
* @param participantId the participant's unique id
* @return the participant with the given id
*/
- public SearchParticipant getParticipant(String participantId) {
+ public LuceneSearchParticipant getParticipant(String participantId) {
ParticipantDescriptor desc = (ParticipantDescriptor)searchParticipantsById.get(participantId);
if (desc != null) {
return desc.getParticipant();
@@ -316,7 +310,7 @@ public class LocalSearchManager {
* @return
*/
- public SearchParticipant getParticipant(String pluginId, String fileName) {
+ public LuceneSearchParticipant getParticipant(String pluginId, String fileName) {
ArrayList list = getParticipantDescriptors(pluginId);
if (list == null)
return null;
@@ -360,10 +354,16 @@ public class LocalSearchManager {
public Set getPluginsWithSearchParticipants() {
HashSet set = new HashSet();
- addSearchBindings(set);
- addLuceneSearchBindings(set);
+ IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
+ SEARCH_PARTICIPANT_XP_FULLNAME);
+
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement element = elements[i];
+ if (element.getName().equals("binding") || element.getName().equals("searchParticipant")) //$NON-NLS-1$//$NON-NLS-2$
+ set.add(element.getContributor().getName());
+ }
// must ask global search participants directly
- SearchParticipant[] gps = getGlobalParticipants();
+ LuceneSearchParticipant[] gps = getGlobalParticipants();
for (int i = 0; i < gps.length; i++) {
Set ids;
try {
@@ -378,28 +378,6 @@ public class LocalSearchManager {
return set;
}
- private void addSearchBindings(HashSet set) {
- IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
- SEARCH_PARTICIPANT_XP_FULLNAME);
-
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
- if (element.getName().equals("binding") || element.getName().equals("searchParticipant")) //$NON-NLS-1$//$NON-NLS-2$
- set.add(element.getContributor().getName());
- }
- }
-
- private void addLuceneSearchBindings(HashSet set) {
- IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
- LUCENE_SEARCH_PARTICIPANT_XP_FULLNAME);
-
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
- if (element.getName().equals("binding") || element.getName().equals("searchParticipant")) //$NON-NLS-1$//$NON-NLS-2$
- set.add(element.getContributor().getName());
- }
- }
-
/**
* Loops through all the loaded search participants and notifies them that they can drop the
* cached data to reduce runtime memory footprint.
@@ -414,7 +392,7 @@ public class LocalSearchManager {
private ArrayList createSearchParticipants(String pluginId) {
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
- LUCENE_SEARCH_PARTICIPANT_XP_FULLNAME);
+ SEARCH_PARTICIPANT_XP_FULLNAME);
if (elements.length == 0)
return null;
ArrayList list = null;
@@ -511,27 +489,22 @@ public class LocalSearchManager {
* @return an array of the global search participants.
*/
- public SearchParticipant[] getGlobalParticipants() {
+ public LuceneSearchParticipant[] getGlobalParticipants() {
if (globalSearchParticipants == null) {
createGlobalSearchParticipants();
}
ArrayList result = new ArrayList();
for (int i = 0; i < globalSearchParticipants.size(); i++) {
ParticipantDescriptor desc = (ParticipantDescriptor) globalSearchParticipants.get(i);
- SearchParticipant p = desc.getParticipant();
+ LuceneSearchParticipant p = desc.getParticipant();
if (p != null)
result.add(p);
}
- return (SearchParticipant[]) result.toArray(new SearchParticipant[result.size()]);
+ return (LuceneSearchParticipant[]) result.toArray(new LuceneSearchParticipant[result.size()]);
}
private void createGlobalSearchParticipants() {
globalSearchParticipants = new ArrayList();
- addSearchParticipants();
- addLuceneSearchParticipants();
- }
-
- private void addSearchParticipants() {
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
SEARCH_PARTICIPANT_XP_FULLNAME);
for (int i = 0; i < elements.length; i++) {
@@ -547,22 +520,6 @@ public class LocalSearchManager {
}
}
- private void addLuceneSearchParticipants() {
- IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
- LUCENE_SEARCH_PARTICIPANT_XP_FULLNAME);
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
- if (!element.getName().equals(SEARCH_PARTICIPANT_XP_NAME))
- continue;
- if (element.getAttribute("extensions") != null) //$NON-NLS-1$
- continue;
- if (!isParticipantEnabled(String.valueOf(true).equals(element.getAttribute("headless")))) //$NON-NLS-1$
- continue;
- ParticipantDescriptor desc = new ParticipantDescriptor(element);
- globalSearchParticipants.add(desc);
- }
- }
-
private ArrayList getParticipantDescriptors(String pluginId) {
Object result = searchParticipantsByPlugin.get(pluginId);
if (result == null) {
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java
deleted file mode 100644
index 95729a3dc..000000000
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.help.internal.search;
-
-import java.io.StringReader;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.eclipse.help.search.ISearchDocument;
-
-/**
- * Class which adapts a Lucene Document to ISearchDocument.
- */
-
-public class LuceneSearchDocument implements ISearchDocument {
-
- private Document doc;
-
- public LuceneSearchDocument(Document document) {
- this.doc = document;
- }
-
- public void addTitle(String title) {
- doc.add(new Field("title", title, Field.Store.NO, Field.Index.TOKENIZED)); //$NON-NLS-1$
- doc.add(new Field("exact_title", title, Field.Store.NO, Field.Index.TOKENIZED)); //$NON-NLS-1$
- doc.add(new Field("raw_title", title, Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$
- }
-
- public void addSummary(String summary) {
- doc.add(new Field("summary", summary, Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$
- }
-
- public void addContents(String contents) {
- doc.add(new Field("contents", new StringReader(contents))); //$NON-NLS-1$
- doc.add(new Field("exact_contents", new StringReader(contents))); //$NON-NLS-1$
- }
-
- public void setHasFilters(boolean hasFilters) {
- doc.add(new Field("filters", Boolean.toString(hasFilters), Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$
- }
-
- public Document getDocument() {
- return doc;
- }
-
-}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchParticipantAdapter.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchParticipantAdapter.java
deleted file mode 100644
index d13bf4d00..000000000
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchParticipantAdapter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.help.internal.search;
-
-/**
- * Adapts a LuceneSearchParticipant to SearchParticipant
- */
-
-import java.net.URL;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.help.search.IHelpSearchIndex;
-import org.eclipse.help.search.ISearchDocument;
-import org.eclipse.help.search.LuceneSearchParticipant;
-import org.eclipse.help.search.SearchParticipant;
-
-public class LuceneSearchParticipantAdapter extends SearchParticipant {
-
- private LuceneSearchParticipant searchParticipant;
-
- public LuceneSearchParticipantAdapter(LuceneSearchParticipant participant) {
- this.searchParticipant = participant;
- }
-
- public IStatus addDocument(IHelpSearchIndex index, String pluginId, String name, URL url, String id,
- ISearchDocument doc) {
- // In the help system the only class that implements ISearchDocument is LuceneSearchDocument
- // and the only class that implements IHelpSearchIndex is SearchIndex
- LuceneSearchDocument luceneDoc = (LuceneSearchDocument)doc;
- SearchIndex searchIndex = (SearchIndex) index;
- return searchParticipant.addDocument(searchIndex, pluginId, name, url, id, luceneDoc.getDocument());
- }
-
- public Set getAllDocuments(String locale) {
- return searchParticipant.getAllDocuments(locale);
- }
-
- public void clear() {
- searchParticipant.clear();
- }
-
- public boolean equals(Object obj) {
- return searchParticipant.equals(obj);
- }
-
- public Set getContributingPlugins() {
- return searchParticipant.getContributingPlugins();
- }
-
- public int hashCode() {
- return searchParticipant.hashCode();
- }
-
- public boolean open(String id) {
- return searchParticipant.open(id);
- }
-
-}
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 037ce28dc..85a6137ae 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, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 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,10 +60,8 @@ 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.SearchParticipant;
+import org.eclipse.help.search.LuceneSearchParticipant;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
@@ -71,7 +69,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, IHelpSearchIndex {
+public class SearchIndex implements ISearchIndex {
private IndexReader ir;
@@ -194,8 +192,8 @@ public class SearchIndex implements ISearchIndex, IHelpSearchIndex {
if (relativePath != null) {
doc.add(new Field(FIELD_INDEX_ID, relativePath, Field.Store.YES, Field.Index.UN_TOKENIZED));
}
- // check for the explicit search participant.
- SearchParticipant participant = null;
+ // NEW: check for the explicit search participant.
+ LuceneSearchParticipant participant = null;
HelpURLConnection urlc = new HelpURLConnection(url);
String id = urlc.getValue("id"); //$NON-NLS-1$
String pid = urlc.getValue("participantId"); //$NON-NLS-1$
@@ -205,7 +203,7 @@ public class SearchIndex implements ISearchIndex, IHelpSearchIndex {
if (participant == null)
participant = BaseHelpSystem.getLocalSearchManager().getParticipant(pluginId, name);
if (participant != null) {
- IStatus status = participant.addDocument(this, pluginId, name, url, id, new LuceneSearchDocument(doc));
+ IStatus status = participant.addDocument(this, pluginId, name, url, id, doc);
if (status.getSeverity() == IStatus.OK) {
String filters = doc.get("filters"); //$NON-NLS-1$
indexedDocs.put(name, filters != null ? filters : "0"); //$NON-NLS-1$
@@ -1047,11 +1045,11 @@ public class SearchIndex implements ISearchIndex, IHelpSearchIndex {
public IStatus addDocument(String pluginId, String name, URL url, String id, Document doc) {
// try a registered participant for the file format
- SearchParticipant participant = BaseHelpSystem.getLocalSearchManager()
+ LuceneSearchParticipant participant = BaseHelpSystem.getLocalSearchManager()
.getParticipant(pluginId, name);
if (participant != null) {
try {
- return participant.addDocument(this, pluginId, name, url, id, new LuceneSearchDocument(doc));
+ return participant.addDocument(this, pluginId, name, url, id, doc);
}
catch (Throwable t) {
return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR,
@@ -1062,10 +1060,4 @@ public class SearchIndex implements ISearchIndex, IHelpSearchIndex {
// 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());
- }
}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelp.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelp.java
index aa76a85df..9bf6a4290 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelp.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelp.java
@@ -92,7 +92,7 @@ public class LocalHelp implements ISearchEngine2 {
return false;
String participantId = id.substring(0, sep);
id = id.substring(sep+1);
- SearchParticipant participant = BaseHelpSystem.getLocalSearchManager().getGlobalParticipant(participantId);
+ LuceneSearchParticipant participant = BaseHelpSystem.getLocalSearchManager().getGlobalParticipant(participantId);
if (participant==null)
return false;
try {
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/IHelpSearchIndex.java b/org.eclipse.help.base/src/org/eclipse/help/search/IHelpSearchIndex.java
deleted file mode 100644
index 03b73058a..000000000
--- a/org.eclipse.help.base/src/org/eclipse/help/search/IHelpSearchIndex.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.help.search;
-
-import java.net.URL;
-
-
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * Represents a Lucene index for one locale. The interface is used
- * to allow participants to delegate indexing of documents outside
- * of the TOC using the same algorithms as those in TOC.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 3.5
- */
-
-public interface IHelpSearchIndex {
-
- /**
- * Adds a document to the search index database by parsing it using one of the file-based search
- * participants, or the default HTML search participant. Use this method when encountering
- * documents outside of TOC that are nevertheless of the known format and help system knows how
- * to handle.
- *
- * @param pluginId
- * the id of the contributing plug-in
- * @param name
- * the name of the document
- * @param url
- * the URL of the document using format '/pluginId/href'
- * @param id
- * the unique id of this document as defined in the participant
- * @param doc
- * the document to be added
- * @return the status of the operation
- */
- IStatus addSearchableDocument(String pluginId, String name, URL url, String id, ISearchDocument doc);
-
- /**
- * A search index is created for each locale.
- * @return the locale associated with this index.
- */
- String getLocale();
-}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/ISearchDocument.java b/org.eclipse.help.base/src/org/eclipse/help/search/ISearchDocument.java
deleted file mode 100644
index 06aa0868e..000000000
--- a/org.eclipse.help.base/src/org/eclipse/help/search/ISearchDocument.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.help.search;
-
-/**
- * Represents a document in the search index. This interface is used by
- * clients which implement the search participant extension point. While the
- * help system uses the Lucene classes internally this interface does not
- * import anything from Lucene and enables the API to remain binary compatible
- * whatever changes are made in Lucene.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 3.5
- */
-
-public interface ISearchDocument {
-
- /**
- * @param title the title which will be shown in the search results summary
- */
- public void addTitle(String title);
-
- /**
- * @param summary the summary which will be used when displaying search results.
- */
- public void addSummary(String summary);
-
- /**
- * @param contents the text which will be used when performing a search. The search index
- * will parse the contents and store the results in a database for rapid retrieval.
- */
- public void addContents(String contents);
-
- /**
- * Allows search participant to indicate that a document will be processed
- * at runtime and that parts of the contents may not be displayed to the
- * user, causing a match in the search to be shown as a potential match.
- * By default documents are considered to be unfiltered so this function
- * need only be called to indicate that a document is filtered
- */
- public void setHasFilters(boolean hasFilters);
-
-}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipant.java b/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipant.java
deleted file mode 100644
index 89dfa6a2e..000000000
--- a/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipant.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.help.search;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.help.internal.util.ResourceLocator;
-import org.osgi.framework.Bundle;
-
-/**
- * Participant in the help search. A plug-in can contribute instance of SearchParticipant to
- * <code>"org.eclipse.help.search.searchParticipant"</code> extension point. Search
- * participant is responsible for adding the content of documents it is responsible for into the
- * help system's search index. Once in the index, the document becomes searchable and can produce
- * search hits. There are two ways of using the participant:
- * <ol>
- * <li> For adding documents that are part of the help's TOC that have content formats not known to
- * the default indexer (which are essentially all documents that are not of HTML format). In this
- * case, the help system knows about the documents because they are in TOC but does not know how to
- * index them. Because of the non-HTML format, help search participants are normally accompanied by
- * the help content producers that are responsible for transforming the unknown format into HTML on
- * the fly. <br>
- * <br>
- * When used in this mode, search participants must be registered with file extensions they handle.
- * Based on the file extension mapping, they will be the first to get a chance at indexing the
- * document with the matching extension.<br>
- * <br>
- * </li>
- * <li> For adding documents that are outside of the help's TOC. In this case, the documents are
- * completely unknown to the help system. Search participants are responsible for providing a set of
- * documents they know about and are not supposed to declare file extensions they can handle. They
- * are also responsible for opening these documents when asked because the help system will not be
- * able to open them in any meaningful way. </li>
- * </ol>
- *
- * @since 3.5
- */
-public abstract class SearchParticipant {
-
- private static final HashSet EMPTY_SET = new HashSet();
-
- private String id;
-
- /**
- * Initializes the participant with the unique identifier from the registry. The method is
- * called by the help system - subclasses are not supposed to call it.
- *
- * @param id
- * the unique identifier of this participant
- */
-
- public final void init(String id) {
- this.id = id;
- }
-
- /**
- * Returns the unique identifier of this participant.
- *
- * @return the unique id
- */
- public final String getId() {
- return id;
- }
-
- /**
- * Adds the document to the search index.
- *
- * @param index
- * the abstract representation of the help index that is currently running. Indexing
- * known file types in participants that manage documents outside the TOC can be
- * delegated to the index.
- * @param pluginId
- * the plug-in that owns the document
- * @param name
- * the name of the document to index
- * @param url
- * the url of the document to index
- * @param id
- * the unique id associated with this document
- * @param doc
- * the document to add searchable content to
- * @return the status of the indexing operation. A successful operation should return
- * <code>Status.OK</code>.
- */
- public abstract IStatus addDocument(IHelpSearchIndex index, String pluginId, String name, URL url, String id,
- ISearchDocument doc);
-
- /**
- * Returns all the documents that this participant knows about. This method is only used for
- * participants that handle documents outside of the help system's TOC.
- *
- * @param locale
- * the index locale
- *
- * @return a set of hrefs for documents managed by this participant.
- */
- public Set getAllDocuments(String locale) {
- return EMPTY_SET;
- }
-
- /**
- * Returns a set of identifiers of plug-ins that contribute indexable documents. This method is
- * only used for participants that handle documents outside of the help system's TOC.
- *
- * @return a set of contributing plug-in ids
- */
-
- public Set getContributingPlugins() {
- return EMPTY_SET;
- }
-
- /**
- * A utility method that resolves a file name that contains '$'-based substitution variables.
- *
- * @param pluginId
- * the identifier of the originating plug-in
- * @param fileName
- * the source file name
- * @param locale
- * the locale to use when resolving nl variable
- * @return the plug-in relative file name with resolved variables
- */
-
- protected static String resolveVariables(String pluginId, String fileName, String locale) {
- if (fileName.indexOf('$') == -1)
- return fileName;
- ArrayList prefix = ResourceLocator.getPathPrefix(locale);
- Bundle bundle = Platform.getBundle(pluginId);
- if (bundle == null)
- return fileName;
- URL url = ResourceLocator.find(bundle, new Path(fileName), prefix);
- URL root = FileLocator.find(bundle, new Path(""), null); //$NON-NLS-1$
- return url.toString().substring(root.toString().length());
- }
-
- /**
- * A utility method that adds a title to the document.
- *
- * @param title
- * the title string
- * @param doc
- * the document
- */
-
- protected void addTitle(String title, ISearchDocument doc) {
- doc.addTitle(title);
- }
-
- /**
- * Help system does not know how to open documents outside of the system's TOC. Global search
- * participants that bring additional documents into the index when
- * <code>getAllDocuments(String)</code> have a chance to open the document when it is part of
- * the search results. The default implementation returns <code>false</code> indicating that
- * the help system should open the document. In most cases this is wrong for most of XML files
- * that are in some interesting way.
- *
- * @param id
- * a participant-specific identifier that completely represents a search result
- *
- * @return <code>true</code> if the file has been opened correctly or <code>false</code> to
- * allow the help system to try to open the document.
- */
-
- public boolean open(String id) {
- return false;
- }
-
- /**
- * Signals to the participant that the indexing operation has finished and that cached resources
- * can be disposed to free up memory. The participant itself is still kept around (hence this is
- * semantically different from <code>dispose</code>).
- */
- public void clear() {
- }
-}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java b/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java
deleted file mode 100644
index ec64fc83f..000000000
--- a/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.help.search;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.net.URL;
-import java.util.Stack;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.help.internal.base.HelpBasePlugin;
-import org.eclipse.help.internal.dynamic.DocumentReader;
-import org.eclipse.help.internal.dynamic.ExtensionHandler;
-import org.eclipse.help.internal.dynamic.IncludeHandler;
-import org.eclipse.help.internal.dynamic.ProcessorHandler;
-import org.eclipse.help.internal.dynamic.XMLProcessor;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * An abstract search participants for adding XML documents to the search index. Subclass it
- * and implement or override protected methods to handle parsing of the document.
- *
- * @since 3.5
- */
-public abstract class SearchParticipantXML extends SearchParticipant {
- private Stack stack = new Stack();
- private SAXParser parser;
- private XMLProcessor processor;
- private boolean hasFilters;
-
- /**
- * Class that implements this interface is used to store data obtained during the parsing phase.
- */
- protected interface IParsedXMLContent {
-
- /**
- * Returns the locale of the index.
- *
- * @return the locale string
- */
- String getLocale();
-
- /**
- * Sets the title of the parsed document for indexing.
- *
- * @param title
- * the document title
- */
- void setTitle(String title);
-
- /**
- * Sets the optional summary of the parsed document that can be later rendered for the
- * search hits.
- *
- * @param summary
- * the short document summary
- */
- void addToSummary(String summary);
-
- /**
- * Adds the text to the content buffer for indexing.
- *
- * @param text
- * the text to add to the document content buffer
- */
- void addText(String text);
- }
-
- private static class ParsedXMLContent implements IParsedXMLContent {
- private StringBuffer buffer = new StringBuffer();
- private StringBuffer summary = new StringBuffer();
- private String title;
- private String locale;
- private static int SUMMARY_LENGTH = 200;
-
- public ParsedXMLContent(String locale) {
- this.locale = locale;
- }
-
- public String getLocale() {
- return locale;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public void addToSummary(String text) {
- if (summary.length() >= SUMMARY_LENGTH)
- return;
- if (summary.length() > 0)
- summary.append(" "); //$NON-NLS-1$
- summary.append(text);
- if (summary.length() > SUMMARY_LENGTH)
- summary.delete(SUMMARY_LENGTH, summary.length());
- }
-
- public void addText(String text) {
- if (buffer.length() > 0)
- buffer.append(" "); //$NON-NLS-1$
- buffer.append(text);
- }
-
- public String getContent() {
- return buffer.toString();
- }
-
- public String getSummary() {
- // if the summary starts with the title, trim that part off.
- String summaryStr = summary.toString();
- if (title != null && summaryStr.length() >= title.length()) {
- String header = summaryStr.substring(0, title.length());
- if (header.equalsIgnoreCase(title)) {
- return summaryStr.substring(title.length()).trim();
- }
- }
- return summaryStr;
- }
-
- public String getTitle() {
- return title;
- }
- }
-
- private class XMLHandler extends DefaultHandler {
-
- public ParsedXMLContent data;
-
- public XMLHandler(ParsedXMLContent data) {
- this.data = data;
- }
-
- public void startElement(String uri, String localName, String qName, Attributes attributes)
- throws SAXException {
- stack.push(qName);
- handleStartElement(qName, attributes, data);
- if (attributes.getValue("filter") != null || qName.equalsIgnoreCase("filter")) { //$NON-NLS-1$ //$NON-NLS-2$
- hasFilters = true;
- }
- }
-
- public void endElement(String uri, String localName, String qName) throws SAXException {
- handleEndElement(qName, data);
- String top = (String) stack.peek();
- if (top != null && top.equals(qName))
- stack.pop();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.helpers.DefaultHandler#startDocument()
- */
- public void startDocument() throws SAXException {
- SearchParticipantXML.this.handleStartDocument(data);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.helpers.DefaultHandler#endDocument()
- */
- public void endDocument() throws SAXException {
- SearchParticipantXML.this.handleEndDocument(data);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.helpers.DefaultHandler#processingInstruction(java.lang.String,
- * java.lang.String)
- */
- public void processingInstruction(String target, String pidata) throws SAXException {
- handleProcessingInstruction(target, data);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
- */
- public void characters(char[] characters, int start, int length) throws SAXException {
- if (length == 0)
- return;
- StringBuffer buff = new StringBuffer();
- for (int i = 0; i < length; i++) {
- buff.append(characters[start + i]);
- }
- String text = buff.toString();
- if (text.trim().length() > 0)
- handleText(text, data);
- }
-
- /*
- * Note: throws clause does not declare IOException due to a bug in
- * sun jdk: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6327149
- *
- * @see org.xml.sax.helpers.DefaultHandler#resolveEntity(java.lang.String, java.lang.String)
- */
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
- return new InputSource(new StringReader("")); //$NON-NLS-1$
- }
- }
-
- /**
- * Called when the element has been started.
- *
- * @param name
- * the element name
- * @param attributes
- * the element attributes
- * @param data
- * data the parser content data to update
- */
- protected abstract void handleStartElement(String name, Attributes attributes, IParsedXMLContent data);
-
- /**
- * Called when the element has been ended.
- *
- * @param name
- * the name of the XML element
- * @param data
- * data the parser content data to update
- */
- protected abstract void handleEndElement(String name, IParsedXMLContent data);
-
- /**
- * Called when the XML document has been started.
- *
- * @param data
- * data the parser content data to update
- */
- protected void handleStartDocument(IParsedXMLContent data) {
- }
-
- /**
- * Called when the XML document has been ended.
- *
- * @param data
- * data the parser content data to update
- */
- protected void handleEndDocument(IParsedXMLContent data) {
- }
-
- /**
- * Called when a processing instruction has been encountered.
- *
- * @param type
- * the instruction data
- * @param data
- * the parser content data to update
- */
- protected void handleProcessingInstruction(String type, IParsedXMLContent data) {
- }
-
- /**
- * Called when element body text has been encountered. Use 'getElementStackPath()' to determine
- * the element in question.
- *
- * @param text
- * the body text
- * @param data
- * the parser content data to update
- */
- protected abstract void handleText(String text, IParsedXMLContent data);
-
-
- public IStatus addDocument(IHelpSearchIndex index, String pluginId,
- String name, URL url, String id, ISearchDocument doc) {
- InputStream stream = null;
- try {
- if (parser == null) {
- parser = SAXParserFactory.newInstance().newSAXParser();
- }
- stack.clear();
- hasFilters = false;
- ParsedXMLContent parsed = new ParsedXMLContent(index.getLocale());
- XMLHandler handler = new XMLHandler(parsed);
- stream = url.openStream();
- stream = preprocess(stream, name, index.getLocale());
- parser.parse(stream, handler);
- doc.addContents(parsed.getContent());
- String title = parsed.getTitle();
- if (title != null)
- addTitle(title, doc);
- String summary = parsed.getSummary();
- if (summary != null)
- doc.addSummary(summary);
- if (hasFilters) {
- doc.setHasFilters(true);
- }
- return Status.OK_STATUS;
- } catch (Exception e) {
- return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR,
- "Exception occurred while adding document " + name //$NON-NLS-1$
- + " to index.", //$NON-NLS-1$
- e);
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (IOException e) {
- }
- stream = null;
- }
- }
- }
-
- /**
- * Returns the name of the element that is currently at the top of the element stack.
- *
- * @return the name of the element that is currently at the top of the element stack
- */
-
- protected String getTopElement() {
- return (String) stack.peek();
- }
-
- /**
- * Returns the full path of the current element in the stack separated by the '/' character.
- *
- * @return the path to the current element in the stack.
- */
- protected String getElementStackPath() {
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < stack.size(); i++) {
- if (i > 0)
- buf.append("/"); //$NON-NLS-1$
- buf.append((String) stack.get(i));
- }
- return buf.toString();
- }
-
- /**
- * <p>
- * Pre-processes the given document input stream for the given document name and locale.
- * This implementation will resolve dynamic content that is applicable to searching,
- * e.g. includes and extensions, but not filters. Subclasses may override to do their
- * own pre-processing.
- * </p>
- * <p>
- * For performance, implementations that handle documents that do not support dynamic
- * content should subclass and return the original stream.
- * </p>
- *
- * @param in the input stream for the document content
- * @param name the name of the document as it appears in the index
- * @param locale the locale code, e.g. "en_US"
- * @return the processed content
- * @since 3.3
- */
- protected InputStream preprocess(InputStream in, String name, String locale) {
- if (processor == null) {
- DocumentReader reader = new DocumentReader();
- processor = new XMLProcessor(new ProcessorHandler[] {
- new IncludeHandler(reader, locale),
- new ExtensionHandler(reader, locale)
- });
- }
- try {
- return processor.process(in, name, null);
- }
- catch (Throwable t) {
- String msg = "An error occured while pre-processing user assistance document \"" + name + "\" for search indexing"; //$NON-NLS-1$ //$NON-NLS-2$
- HelpBasePlugin.logError(msg, t);
- return in;
- }
- }
-}
diff --git a/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml b/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml
deleted file mode 100644
index 74d095c4a..000000000
--- a/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 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
- http://www.eclipse.org/legal/epl-v10.html
-
- Contributors:
- IBM Corporation - initial API and implementation
- -->
-
-<participant title = "Participant XML 1">
- <text title="ignored title" summary = "Summary for">
- search word jfplepdl
- </text>
- <text summary = "file Participant XML1">
- search word memdjkemd
- </text>
-</participant>
-
diff --git a/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml b/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml
deleted file mode 100644
index fea9fc6ae..000000000
--- a/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Copyright (c) 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
- http://www.eclipse.org/legal/epl-v10.html
-
- Contributors:
- IBM Corporation - initial API and implementation
- -->
-
-<outer>
-<participant title = "Participant XML 2 - tests nesting">
- <text title="ignored title" summary = "Summary for">
- search word odoeofoedo
- <text summary = "file Participant XML2">
- search word odkeofkeks
- </text>
- </text>
-</participant>
-</outer>
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java
index fa661e6cc..3d0198b60 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java
@@ -35,10 +35,9 @@ public class AllSearchTests extends TestSuite {
addTestSuite(LocaleTest.class);
addTestSuite(AnalyzerTest.class);
addTest(SearchCheatsheet.suite());
+ addTest(SearchIntro.suite());
addTest(EncodedCharacterSearch.suite());
addTest(MetaKeywords.suite());
- addTest(SearchParticipantTest.suite());
- addTest(SearchParticipantXMLTest.suite());
addTest(LuceneParticipantTest.suite());
addTest(LuceneXMLParticipantTest.suite());
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipant.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipant.java
deleted file mode 100644
index bbd340ab3..000000000
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipant.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ua.tests.help.search;
-
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.help.search.IHelpSearchIndex;
-import org.eclipse.help.search.ISearchDocument;
-import org.eclipse.help.search.SearchParticipant;
-
-public class MockSearchParticipant extends SearchParticipant {
-
- private static final String DOC_1 = "/org.eclipse.ua.tests/participant1.xml";
- private static final String DOC_2 = "/org.eclipse.ua.tests/participant2.xml";
-
- public Set getAllDocuments(String locale) {
- HashSet set = new HashSet();
- set.add(DOC_1);
- set.add(DOC_2);
- return set;
- }
-
- public IStatus addDocument(IHelpSearchIndex index, String pluginId,
- String name, URL url, String id, ISearchDocument doc) {
- boolean isDoc1 = url.getPath().equals(DOC_1) ;
- String title = isDoc1 ? "Title1" : "Title2";
- String summary = isDoc1? "Summary1" : "Summary2";
- String contents = isDoc1? "jkijkijkk frgeded" : "olhoykk lgktihku";
- doc.addTitle(title);
- doc.addSummary(summary);
- doc.addContents(contents);
- return Status.OK_STATUS;
- }
-
-}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipantXML.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipantXML.java
deleted file mode 100644
index 1f45b4797..000000000
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipantXML.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ua.tests.help.search;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.help.search.SearchParticipantXML;
-import org.xml.sax.Attributes;
-
-public class MockSearchParticipantXML extends SearchParticipantXML {
-
- public static final String DOC_1 = "/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml";
- public static final String DOC_2 = "/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml";
-
- public Set getAllDocuments(String locale) {
- HashSet set = new HashSet();
- set.add(DOC_1 + "?id=xml1" + "?id=xml2");
- set.add(DOC_2);
- return set;
- }
-
- public Set getContributingPlugins() {
- Set result = new HashSet();
- result.add("org.eclipse.ua.tests");
- return result;
- }
-
- protected void handleStartElement(String name, Attributes attributes,
- IParsedXMLContent data) {
- if ("participant".equalsIgnoreCase(name)) {
- data.setTitle(attributes.getValue("title"));
- }
- String summary = attributes.getValue("summary");
- if (summary != null) {
- data.addToSummary(summary);
- }
- }
-
- protected void handleEndElement(String name, IParsedXMLContent data) {
- }
-
- protected void handleText(String text, IParsedXMLContent data) {
- String top = getTopElement();
- if ("text".equalsIgnoreCase(top)) {
- data.addText(text);
- }
- }
-
- public boolean open(String id) {
- System.out.println("Open " + id);
- return true;
- }
-
-}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java
deleted file mode 100644
index 223e42a99..000000000
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ua.tests.help.search;
-
-
-import org.eclipse.help.internal.search.SearchHit;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-public class SearchParticipantTest extends TestCase {
-
- /*
- * Returns an instance of this Test.
- */
- public static Test suite() {
- return new TestSuite(SearchParticipantTest.class);
- }
-
- public void testSearchFirstWordInFirstDoc() {
- SearchTestUtils.searchAllLocales("jkijkijkk", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
- }
-
- public void testSearchLastWordInFirstDoc() {
- SearchTestUtils.searchAllLocales("frgeded", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
- }
-
- public void testSearchUsingAndInFirstDoc() {
- SearchTestUtils.searchAllLocales("jkijkijkk AND frgeded", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
- }
-
- public void testSearchUsingAndInSeparateDocs() {
- SearchTestUtils.searchAllLocales("jduehdye and olhoykk", new String[0]);
- }
-
- public void testSearchExactMatch() {
- SearchTestUtils.searchAllLocales("\"jkijkijkk frgeded\"", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
- }
-
- public void testSearchExactMatchNotFound() {
- SearchTestUtils.searchAllLocales("\"frgeded jkijkijkk\"", new String[0]);
- }
-
- public void testSearchWordInSecondDoc() {
- SearchTestUtils.searchAllLocales("olhoykk", new String[] { "/org.eclipse.ua.tests/participant2.xml" });
- }
-
- public void testReturnedTitle() {
- SearchHit[] hits = SearchTestUtils.getSearchHits("jkijkijkk", "en");
- assertEquals(hits.length,1);
- assertEquals("Title1", hits[0].getLabel());
- }
-
- public void testReturnedSummary() {
- SearchHit[] hits = SearchTestUtils.getSearchHits("jkijkijkk", "en");
- assertEquals(hits.length,1);
- assertEquals("Summary1", hits[0].getSummary());
- }
-
-}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java
deleted file mode 100644
index 181c3644e..000000000
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ua.tests.help.search;
-
-
-import org.eclipse.help.internal.search.SearchHit;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-public class SearchParticipantXMLTest extends TestCase {
-
- /*
- * Returns an instance of this Test.
- */
- public static Test suite() {
- return new TestSuite(SearchParticipantXMLTest.class);
- }
-
- public void testSearchFirstWordInFirstDoc() {
- SearchTestUtils.searchAllLocales("jfplepdl", new String[] { MockSearchParticipantXML.DOC_1 });
- }
-
- public void testSearchLastWordInFirstDoc() {
- SearchTestUtils.searchAllLocales("memdjkemd", new String[] { MockSearchParticipantXML.DOC_1 });
- }
-
- public void testSearchWordFromOuterElement() {
- SearchTestUtils.searchAllLocales("odoeofoedo", new String[] { MockSearchParticipantXML.DOC_2 });
- }
-
- public void testSearchWordFromNestedElement() {
- SearchTestUtils.searchAllLocales("odkeofkeks", new String[] { MockSearchParticipantXML.DOC_2 });
- }
-
- public void testReturnedTitle() {
- SearchHit[] hits = SearchTestUtils.getSearchHits("jfplepdl", "en");
- assertEquals(hits.length,1);
- assertEquals("Participant XML 1", hits[0].getLabel());
- }
-
- public void testReturnedSummary() {
- SearchHit[] hits = SearchTestUtils.getSearchHits("jfplepdl", "en");
- assertEquals(hits.length,1);
- assertEquals("Summary for file Participant XML1", hits[0].getSummary());
- }
-
- public void testReturnedTitleNestedCase() {
- SearchHit[] hits = SearchTestUtils.getSearchHits("odoeofoedo", "en");
- assertEquals(hits.length,1);
- assertEquals("Participant XML 2 - tests nesting", hits[0].getLabel());
- }
-
- public void testReturnedSummaryNestedCase() {
- SearchHit[] hits = SearchTestUtils.getSearchHits("odoeofoedo", "en");
- assertEquals(hits.length,1);
- assertEquals("Summary for file Participant XML2", hits[0].getSummary());
- }
-
-}
diff --git a/org.eclipse.ua.tests/plugin.xml b/org.eclipse.ua.tests/plugin.xml
index 936209c2d..4aa87542d 100644
--- a/org.eclipse.ua.tests/plugin.xml
+++ b/org.eclipse.ua.tests/plugin.xml
@@ -621,22 +621,5 @@
participant="org.eclipse.ua.tests.help.search.MockLuceneXMLParticipant">
</searchParticipant>
</extension>
- <extension
- point="org.eclipse.help.base.searchParticipant">
- <searchParticipant
- headless="false"
- icon="icons/sample4.gif"
- id="org.eclipse.ua.tests.searchParticipant"
- name="Mock Search Participant"
- participant="org.eclipse.ua.tests.help.search.MockSearchParticipant">
- </searchParticipant>
- <searchParticipant
- headless="false"
- icon="icons/sample4.gif"
- id="org.eclipse.ua.tests.searchParticipantXml"
- name="Mock Search Participant for XML"
- participant="org.eclipse.ua.tests.help.search.MockSearchParticipantXML">
- </searchParticipant>
- </extension>
</plugin>

Back to the top