Class SearchDocument


  • public abstract class SearchDocument
    extends Object
    A search document encapsulates a content to be either indexed or searched in. A search participant creates a search document.

    This class is intended to be subclassed by clients.

    Since:
    3.0
    • Constructor Detail

      • SearchDocument

        protected SearchDocument​(String documentPath,
                                 SearchParticipant participant)
        Creates a new search document. The given document path is a string that uniquely identifies the document. Most of the time it is a workspace-relative path, but it can also be a file system path, or a path inside a zip file.
        Parameters:
        documentPath - the path to the document, or null if none
        participant - the participant that creates the search document
    • Method Detail

      • getByteContents

        public abstract byte[] getByteContents()
        Returns the contents of this document. Contents may be different from actual resource at corresponding document path, in case of preprocessing.

        This method must be implemented in subclasses.

        Note: some implementation may choose to cache the contents directly on the document for performance reason. However, this could induce scalability issues due to the fact that collections of documents are manipulated throughout the search operation, and cached contents would then consume lots of memory until they are all released at once in the end.

        Returns:
        the contents of this document, or null if none
      • getCharContents

        public abstract char[] getCharContents()
        Returns the contents of this document. Contents may be different from actual resource at corresponding document path due to preprocessing.

        This method must be implemented in subclasses.

        Note: some implementation may choose to cache the contents directly on the document for performance reason. However, this could induce scalability issues due to the fact that collections of documents are manipulated throughout the search operation, and cached contents would then consume lots of memory until they are all released at once in the end.

        Returns:
        the contents of this document, or null if none
      • getEncoding

        public abstract String getEncoding()
        Returns the encoding for this document.

        This method must be implemented in subclasses.

        Returns:
        the encoding for this document, or null if none
      • getParser

        public org.eclipse.jdt.internal.compiler.SourceElementParser getParser()
        Restriction:
        This method is not intended to be referenced by clients.
        Restriction:
        This method is not intended to be re-implemented or extended by clients.
      • getParticipant

        public final SearchParticipant getParticipant()
        Returns the participant that created this document.
        Returns:
        the participant that created this document
      • getPath

        public final String getPath()
        Returns the path to the original document to publicly mention in index or search results. This path is a string that uniquely identifies the document. Most of the time it is a workspace-relative path, but it can also be a file system path, or a path inside a zip file.
        Returns:
        the path to the document
      • setIndex

        public void setIndex​(org.eclipse.jdt.internal.core.index.Index indexToSet)
        Restriction:
        This method is not intended to be referenced by clients.
        Restriction:
        This method is not intended to be re-implemented or extended by clients.
      • setParser

        public void setParser​(org.eclipse.jdt.internal.compiler.SourceElementParser sourceElementParser)
        Restriction:
        This method is not intended to be referenced by clients.
        Restriction:
        This method is not intended to be re-implemented or extended by clients.
      • shouldIndexResolvedDocument

        public boolean shouldIndexResolvedDocument()
        Restriction:
        This method is not intended to be referenced by clients.
        Restriction:
        This method is not intended to be re-implemented or extended by clients.