org.eclipse.wst.jsdt.core.search

## Class SearchDocument

- java.lang.Object
- - org.eclipse.wst.jsdt.internal.core.search.indexing.InternalSearchDocument
  - - org.eclipse.wst.jsdt.core.search.SearchDocument

    public abstract class SearchDocument
    extends org.eclipse.wst.jsdt.internal.core.search.indexing.InternalSearchDocument

A search document encapsulates a content to be either indexed or searched in. A search particpant creates a search document.

This class is intended to be subclassed by clients.

Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

### Constructor Summary

Constructors
`protected` `SearchDocument(java.lang.String documentPath, SearchParticipant participant)` Creates a new search document.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`void` `addIndexEntry(char[] category, char[] key)` Adds the given index entry (category and key) coming from this document to the index.
`abstract byte[]` `getByteContents()` Returns the contents of this document.
`abstract char[]` `getCharContents()` Returns the contents of this document.
`abstract java.lang.String` `getEncoding()` Returns the encoding for this document.
`IJavaScriptElement` `getJavaElement()`
`SearchParticipant` `getParticipant()` Returns the participant that created this document.
`java.lang.String` `getPath()` Returns the path to the original document to publicly mention in index or search results.
`boolean` `isVirtual()`
`void` `removeAllIndexEntries()` Removes all index entries from the index for the given document.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SearchDocument

    protected SearchDocument(java.lang.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

#### addIndexEntry

    public void addIndexEntry(char[] category,
                              char[] key)

Adds the given index entry (category and key) coming from this document to the index. This method must be called from `SearchParticipant#indexDocument(SearchDocument document, org.eclipse.core.runtime.IPath indexPath)`.

Overrides:
  `addIndexEntry` in class `org.eclipse.wst.jsdt.internal.core.search.indexing.InternalSearchDocument`
Parameters:
  `category` - the category of the index entry
  `key` - the key of the index entry

#### 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 java.lang.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

#### getParticipant

    public final SearchParticipant getParticipant()

Returns the participant that created this document.

Returns:
  the participant that created this document

#### getPath

    public final java.lang.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.

Overrides:
  `getPath` in class `org.eclipse.wst.jsdt.internal.core.search.indexing.InternalSearchDocument`
Returns:
  the path to the document

#### removeAllIndexEntries

    public void removeAllIndexEntries()

Removes all index entries from the index for the given document. This method must be called from `SearchParticipant#indexDocument(SearchDocument document, org.eclipse.core.runtime.IPath indexPath)`.

Overrides:
  `removeAllIndexEntries` in class `org.eclipse.wst.jsdt.internal.core.search.indexing.InternalSearchDocument`

#### isVirtual

    public boolean isVirtual()

#### getJavaElement

    public IJavaScriptElement getJavaElement()