public interface Index
Modifier and Type | Field and Description |
---|---|
static java.net.URL |
END_OF_RESULTS
Marker used to indicate the last result of an index query.
|
static int |
FLAGS_NONE
Value indicating that no flags are set.
|
static QueryResult |
LAST_RESULT
Marker used to indicate the last result of an index query.
|
Modifier and Type | Method and Description |
---|---|
void |
blockingBuild()
Builds the index on the calling thread.
|
java.net.URL[] |
blockingQuery(QueryCriteria criteria)
Query the index on the calling thread.
|
java.util.Collection<QueryResult> |
blockingQueryEx(QueryCriteria criteria)
Query the index on the calling thread.
|
BackgroundTask |
build()
Request that the index be built in a background task.
|
QueryProgress |
findNodes(java.lang.Class nodeClass,
ResultCallback<Node> callback)
Convenience method to find all
Nodes of the given type in the
scope of this index. |
QueryProgress |
findNodes(QueryCriteria criteria,
java.lang.Class nodeClass,
ResultCallback<Node> callback)
Convenience method to find all
Nodes of the given type in the
scope of this index, that also match the given crieria. |
int[][] |
locate(java.net.URL url,
java.lang.Object key,
java.lang.Object value)
Locate the matches for the given data in the given file.
|
void |
lock()
Locks the index.
|
BackgroundTask<java.net.URL[]> |
query(QueryCriteria criteria)
Query the index in a background task.
|
BackgroundTask<java.net.URL[]> |
query(QueryCriteria criteria,
java.util.concurrent.BlockingQueue<java.net.URL> queue)
Query the index in a background task.
|
QueryProgress |
query(QueryCriteria criteria,
ResultCallback<java.net.URL> callback)
Query the index in a background task.
|
BackgroundTask<java.util.Collection<QueryResult>> |
queryEx(QueryCriteria criteria)
Query the index in a background task.
|
BackgroundTask<java.util.Collection<QueryResult>> |
queryEx(QueryCriteria criteria,
java.util.concurrent.BlockingQueue<QueryResult> queue)
Query the index in a background task.
|
QueryProgress |
queryEx(QueryCriteria criteria,
ResultCallback<QueryResult> callback)
Query the index in a background task.
|
void |
release()
Release this index when it is no longer needed.
|
void |
unlock()
Unlocks the index.
|
static final java.net.URL END_OF_RESULTS
static final QueryResult LAST_RESULT
static final int FLAGS_NONE
void lock() throws java.lang.InterruptedException, LockFailedException
blocking queries
. Once the index is locked,
multiple blocking queries can be run before unlocking. The index will be
updated at most one time while it is locked. This ensures that the
results of the queries are consistent, and improves performance over
locking the index seaprately for each query (in which case, the index
could be updated before each query).Note that locking the index does not prevent other callers from locking or querying the index. It only prevents the index data from being updated more than once while there is at least one call to lock() that has not been matched by a corresponding call to unlock().
Callers should take care to ensure that each call to lock() is followed by a corresponding call to unlock(). Typically this is done by following each call to lock() with a try-finally block whose finally clause unlocks the index. Note that the lock operation is interruptible.
java.lang.InterruptedException
- if the lock operation is interruptedLockFailedException
- if the lock failedjava.util.concurrent.RejectedExecutionException
- if the indexing service has been shut downvoid unlock()
BackgroundTask build()
blockingBuild()
must be used instead to prevent deadlock
between the calling thread an the index thread.java.util.concurrent.RejectedExecutionException
- if the indexing service has been shut downvoid blockingBuild() throws java.lang.InterruptedException
locked
before calling this method. This method may take a
long time to execute if the index is not up to date. Callers should take
steps to avoid blocking the UI thread when calling this method.java.util.concurrent.RejectedExecutionException
- if the indexing service has been shut downjava.lang.InterruptedException
java.net.URL[] blockingQuery(QueryCriteria criteria) throws java.lang.InterruptedException, QueryFailedException
locked
before calling this method. This method may take a
long time to execute, for example if the index has not been built yet.
Callers should take steps to avoid blocking the UI thread when calling
this method.criteria
- the query criteriajava.lang.InterruptedException
- if the query is interruptedQueryFailedException
- if the query failedjava.util.Collection<QueryResult> blockingQueryEx(QueryCriteria criteria) throws java.lang.InterruptedException, QueryFailedException
locked
before calling this method. This method may take a
long time to execute, for example if the index has not been built yet.
Callers should take steps to avoid blocking the UI thread when calling
this method.criteria
- the query criteriajava.lang.InterruptedException
- if the query is interruptedQueryFailedException
- if the query failedBackgroundTask<java.net.URL[]> query(QueryCriteria criteria)
criteria
- the query criteriajava.util.concurrent.RejectedExecutionException
- if the indexing service has been shut downBackgroundTask<java.util.Collection<QueryResult>> queryEx(QueryCriteria criteria)
criteria
- the query criteriajava.util.concurrent.RejectedExecutionException
- if the indexing service has been shut downBackgroundTask<java.net.URL[]> query(QueryCriteria criteria, java.util.concurrent.BlockingQueue<java.net.URL> queue)
criteria
- the query critieriaqueue
- the result queuejava.util.concurrent.RejectedExecutionException
- if the indexing service has been shut downBackgroundTask<java.util.Collection<QueryResult>> queryEx(QueryCriteria criteria, java.util.concurrent.BlockingQueue<QueryResult> queue)
criteria
- the query critieriaqueue
- the result queuejava.util.concurrent.RejectedExecutionException
- if the indexing service has been shut downQueryProgress query(QueryCriteria criteria, ResultCallback<java.net.URL> callback)
criteria
- the query criteriacallback
- the callback to call with resultsjava.util.concurrent.RejectedExecutionException
- if the indexing service has been shut downQueryProgress queryEx(QueryCriteria criteria, ResultCallback<QueryResult> callback)
criteria
- the query criteriacallback
- the callback to call with resultsjava.util.concurrent.RejectedExecutionException
- if the indexing service has been shut downint[][] locate(java.net.URL url, java.lang.Object key, java.lang.Object value)
FILE_EXTENSION
.
This method will return empty results for such criteria.This method is for legacy code. It is strongly recommended that new code use the extended query methods to query the location data stored in the index.
url
- the URL of the filekey
- the data keyvalue
- the data value to locateQueryProgress findNodes(java.lang.Class nodeClass, ResultCallback<Node> callback)
Nodes
of the given type in the
scope of this index. This takes advantage of the index data to locate the
Nodes, so the performance will typically be much better than
Project.findChildren(Class)
.
This method will look at every file in the index, and check if it matches
the given Node type. In a large project, this can take some time. If
possible, you can increase performance by supplying additional index query
criteria using the findNodes(QueryCriteria,Class,ResultCallback)
version of this method.
nodeClass
- the node class to findcallback
- the callback to call with resultsjava.util.concurrent.RejectedExecutionException
- if the indexing service has been shut downQueryProgress findNodes(QueryCriteria criteria, java.lang.Class nodeClass, ResultCallback<Node> callback)
Nodes
of the given type in the
scope of this index, that also match the given crieria. This takes
advantage of the index data to locate the Nodes, so the performance will
typically be much better than
Project.findChildren(Class)
.
This method will only look at the Node type of files that match the given
index query critiera. This improves performance over the
findNodes(Class,ResultCallback)
version of this method, which
must check the Node type of every file in the index. For example, if you
use
FILE_EXTENSION
,
only files that have the given file extension will be checked.
criteria
- the index query criterianodeClass
- the node class to findcallback
- the callback to call with resultsjava.util.concurrent.RejectedExecutionException
- if the indexing service has been shut downvoid release()