Class SearchParticipantXML


  • public abstract class SearchParticipantXML
    extends SearchParticipant
    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
    • Constructor Detail

      • SearchParticipantXML

        public SearchParticipantXML()
    • Method Detail

      • handleStartElement

        protected abstract void handleStartElement​(String name,
                                                   Attributes attributes,
                                                   SearchParticipantXML.IParsedXMLContent data)
        Called when the element has been started.
        Parameters:
        name - the element name
        attributes - the element attributes
        data - data the parser content data to update
      • handleEndElement

        protected abstract void handleEndElement​(String name,
                                                 SearchParticipantXML.IParsedXMLContent data)
        Called when the element has been ended.
        Parameters:
        name - the name of the XML element
        data - data the parser content data to update
      • handleStartDocument

        protected void handleStartDocument​(SearchParticipantXML.IParsedXMLContent data)
        Called when the XML document has been started.
        Parameters:
        data - data the parser content data to update
      • handleEndDocument

        protected void handleEndDocument​(SearchParticipantXML.IParsedXMLContent data)
        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 data
        data - the parser content data to update
      • handleText

        protected abstract void handleText​(String text,
                                           SearchParticipantXML.IParsedXMLContent data)
        Called when element body text has been encountered. Use 'getElementStackPath()' to determine the element in question.
        Parameters:
        text - the body text
        data - 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 class SearchParticipant
        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 document
        name - the name of the document to index
        url - the url of the document to index
        id - the unique id associated with this document
        doc - the document to add searchable content to
        Returns:
        the status of the indexing operation. A successful operation should return Status.OK.
      • getTopElement

        protected String 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

        protected String 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

        protected InputStream preprocess​(InputStream in,
                                         String name,
                                         String locale)

        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 content
        name - the name of the document as it appears in the index
        locale - the locale code, e.g. "en_US"
        Returns:
        the processed content
        Since:
        3.3