Package org.eclipse.help.search
Class SearchParticipantXML
java.lang.Object
org.eclipse.help.search.SearchParticipant
org.eclipse.help.search.SearchParticipantXML
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
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
Class that implements this interface is used to store data obtained during the parsing phase. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddDocument
(IHelpSearchIndex index, String pluginId, String name, URL url, String id, ISearchDocument doc) Adds the document to the search index.protected String
Returns the full path of the current element in the stack separated by the '/' character.protected String
Returns the name of the element that is currently at the top of the element stack.protected void
Called when the XML document has been ended.protected abstract void
Called when the element has been ended.protected void
Called when a processing instruction has been encountered.protected void
Called when the XML document has been started.protected abstract void
handleStartElement
(String name, Attributes attributes, SearchParticipantXML.IParsedXMLContent data) Called when the element has been started.protected abstract void
handleText
(String text, SearchParticipantXML.IParsedXMLContent data) Called when element body text has been encountered.protected InputStream
preprocess
(InputStream in, String name, String locale) Pre-processes the given document input stream for the given document name and locale.Methods inherited from class org.eclipse.help.search.SearchParticipant
addTitle, clear, getAllDocuments, getContributingPlugins, getId, init, open, resolveVariables
-
Constructor Details
-
SearchParticipantXML
public SearchParticipantXML()
-
-
Method Details
-
handleStartElement
protected abstract void handleStartElement(String name, Attributes attributes, SearchParticipantXML.IParsedXMLContent data) Called when the element has been started.- Parameters:
name
- the element nameattributes
- the element attributesdata
- data the parser content data to update
-
handleEndElement
Called when the element has been ended.- Parameters:
name
- the name of the XML elementdata
- data the parser content data to update
-
handleStartDocument
Called when the XML document has been started.- Parameters:
data
- data the parser content data to update
-
handleEndDocument
Called when the XML document has been ended.- Parameters:
data
- data the parser content data to update
-
handleProcessingInstruction
protected void handleProcessingInstruction(String type, SearchParticipantXML.IParsedXMLContent data) Called when a processing instruction has been encountered.- Parameters:
type
- the instruction datadata
- the parser content data to update
-
handleText
Called when element body text has been encountered. Use 'getElementStackPath()' to determine the element in question.- Parameters:
text
- the body textdata
- the parser content data to update
-
addDocument
public IStatus addDocument(IHelpSearchIndex index, String pluginId, String name, URL url, String id, ISearchDocument doc) Description copied from class:SearchParticipant
Adds the document to the search index.- Specified by:
addDocument
in classSearchParticipant
- Parameters:
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.pluginId
- the plug-in that owns the documentname
- the name of the document to indexurl
- the url of the document to indexid
- the unique id associated with this documentdoc
- the document to add searchable content to- Returns:
- the status of the indexing operation. A successful operation should return
Status.OK
.
-
getTopElement
Returns the name of the element that is currently at the top of the element stack.- Returns:
- the name of the element that is currently at the top of the element stack
-
getElementStackPath
Returns the full path of the current element in the stack separated by the '/' character.- Returns:
- the path to the current element in the stack.
-
preprocess
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.
For performance, implementations that handle documents that do not support dynamic content should subclass and return the original stream.
- Parameters:
in
- the input stream for the document contentname
- the name of the document as it appears in the indexlocale
- the locale code, e.g. "en_US"- Returns:
- the processed content
- Since:
- 3.3
-