Interface ProjectIndexer
-
@API(type=NOT_EXTENDABLE, src=PUBLIC) public interface ProjectIndexer
Provides access to the project resources, through search methods. An index may or may not be already built.- Since:
- 24.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addProgressMonitor(ProjectIndexerProgressMonitor progressMonitor)
Adds a progress monitor.void
cancelUpdateIndex()
Cancel the indexing process.void
clearIndex()
Clears the index.java.util.List<CompletionProposal>
getCompletionProposals(java.lang.String prefix, CompletionProposalsOptions options)
Gets a list of proposals for a prefix in a document.java.util.Map<java.lang.String,java.lang.String>
getIndexedTextContent()
Gets all the indexed files text content, as a mapping between the resource URI and the content.boolean
hasData()
Checks if the index contains data.boolean
isIndexingInProgress()
Check if the project resource collection is in progress.void
removeProgressMonitor(ProjectIndexerProgressMonitor progressMonitor)
Remove the monitor.void
runAsync(java.lang.Runnable runnable)
Calling indexer methods might block for a read-lock.java.util.List<java.net.URL>
search(java.lang.String searchString, int maxMatches)
Search for keywords.void
updateIndex(boolean forceReindex)
Use this to trigger a reindex.
-
-
-
Method Detail
-
addProgressMonitor
void addProgressMonitor(ProjectIndexerProgressMonitor progressMonitor)
Adds a progress monitor.- Parameters:
progressMonitor
- The monitor to be notified of index events.
-
removeProgressMonitor
void removeProgressMonitor(ProjectIndexerProgressMonitor progressMonitor)
Remove the monitor.- Parameters:
progressMonitor
- The monitor to be removed.
-
updateIndex
void updateIndex(boolean forceReindex)
Use this to trigger a reindex. The indexer can decide to build the index structure if there is none.- Parameters:
forceReindex
-true
drops the entire index structure and reindex all the resources from the project. Iffalse
, it performs a shallow update, reindexing only the modified resources from the project or the new ones.
-
cancelUpdateIndex
void cancelUpdateIndex()
Cancel the indexing process.
-
clearIndex
void clearIndex() throws java.io.IOException
Clears the index. Stops any indexing tasks.Warning: This methods will acquire a write lock on the indexing engine so it might block if a write-lock (indexing) is already in progress. This can be an issue if the calling thread is AWT. Use
runAsync(Runnable)
to avoid this situation.- Throws:
java.io.IOException
- When the index could not be cleared.
-
isIndexingInProgress
boolean isIndexingInProgress()
Check if the project resource collection is in progress.- Returns:
true
if the collection task is in progress.
-
getCompletionProposals
java.util.List<CompletionProposal> getCompletionProposals(java.lang.String prefix, CompletionProposalsOptions options) throws ProjectIndexerException
Gets a list of proposals for a prefix in a document.- Parameters:
prefix
- A prefix is a usually a text, a part of a phrase, from the beginning of the paragraph to the caret position.options
- Set of options.- Returns:
- A list of proposals, never
null
. - Throws:
ProjectIndexerException
- When the index does not contain the content of the files, or if the index is not accessible.
-
search
java.util.List<java.net.URL> search(java.lang.String searchString, int maxMatches) throws ProjectIndexerException
Search for keywords.- Parameters:
searchString
- The list of search keywords.maxMatches
- The maximum amount of documents to return.- Returns:
- the list of document URLs which contain the keywords, sorted by priority.
The list can be
null
if no matches are found. - Throws:
ProjectIndexerException
- Since:
- 27
*********************************
EXPERIMENTAL - Subject to change
********************************
Please note that this API is not marked as final and it can change in one of the next versions of the application. If you have suggestions, comments about it, please let us know.
-
hasData
boolean hasData()
Checks if the index contains data. I.e it was at least once indexed.- Returns:
true
if the index contains data. This istrue
after a indexing operation resulting in the creation of the index on disk.
-
runAsync
void runAsync(java.lang.Runnable runnable)
Calling indexer methods might block for a read-lock.- Parameters:
runnable
- Code that will run asynchronous, on another thread.
-
getIndexedTextContent
java.util.Map<java.lang.String,java.lang.String> getIndexedTextContent() throws java.io.IOException
Gets all the indexed files text content, as a mapping between the resource URI and the content.Warning: This is EXPERIMENTAL API. The resulted text depends on the order in which the indexing was done.
Limitation: Entities, DITA conrefs, keys are not expanded.
- Returns:
- The text content of the indexed files. The key is the URI.
- Throws:
java.io.IOException
- When the index cannot be read.
-
-