public class AbstractIndexProvider extends java.lang.Object implements IIndexProvider
IIndexProvider. This class
needs to be extended by clients for providing the index entries for their
supported resources. For XMI resources refer to XMIIndexProvider
class that parses the XMI artifact instead of loading the resource. The index
entries for a given resource should include a IResourceEntry
and every eObject in the resource should have a corresponding
IEObjectEntry.
Usage:
Create a resource entry:
IResourceEntry resourceEntry = indexWriter.createResourceEntry(getContext(), resourceURI);
Add imports to the entry:
resourceEntry.addImport(importingResourceURI);
Create an EObject entry:
IEObjectEntry eObjectEntry = indexWriter.createEObjectEntry(getContext(), containerURI, eClassifier);
Add reference value to the entry:
eObjectEntry.addEReferenceValue(eReference, referencingEObjectURI);
Add attribute value to the entry:
eObjectEntry.addEAttributeValue(eAttribute, value);
IIndexProvider,
XMIIndexProvider,
IIndexWriterATT_LC_PREFIX, ATT_PREFIX, CONTAINER, ECLASS, IMPORTS, OBJ_RES_URI, OBJ_URI, REFC_PREFIX, REFNC_PREFIX, RES_URI| Constructor and Description |
|---|
AbstractIndexProvider()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
createIndexEntries(org.eclipse.emf.common.util.URI resourceURI,
IIndexWriter indexWriter,
org.eclipse.core.runtime.IProgressMonitor monitor)
Creates index entries for the specified resource URI.
|
protected void |
createIndexEntriesByLoading(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI resourceURI,
IIndexWriter indexWriter,
org.eclipse.core.runtime.IProgressMonitor monitor)
Responsible for creating index entries by loading the resource.
|
protected void |
createIndexEntriesByParsing(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI resourceURI,
IIndexWriter indexWriter,
org.eclipse.core.runtime.IProgressMonitor monitor)
Responsible for creating index entries by parsing the resource if
possible.
|
void |
dispose()
Disposes the index provider.
|
protected IndexContext |
getContext()
Returns the current index context
|
static java.lang.String |
getField(org.eclipse.emf.ecore.EAttribute eAttribute,
java.lang.String attributePrefix)
Get the computed field name for the specified attribute.
|
static java.lang.String |
getField(org.eclipse.emf.ecore.EReference eReference)
Get the computed field name for the specified reference.
|
protected org.eclipse.emf.ecore.resource.ResourceSet |
getResourceSetForLoading(org.eclipse.emf.ecore.resource.ResourceSet defaultResourceSet)
Returns the resource set for loading the resource and creating the index
entries.
|
protected org.eclipse.emf.ecore.resource.ResourceSet |
getResourceSetForParsing(org.eclipse.emf.ecore.resource.ResourceSet defaultResourceSet)
Returns the resource set for parsing the resource and creating the index
entries.
|
void |
init(IndexContext context)
Initializes the index provider with the current index context
|
protected boolean |
shouldParseUsingContextResourceSet(org.eclipse.emf.common.util.URI resourceURI)
Determines whether the context resource set should be used to find a loaded (and unmodified)
resource in order to create EObject entries.
|
public final void createIndexEntries(org.eclipse.emf.common.util.URI resourceURI,
IIndexWriter indexWriter,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws IndexException
IIndexProvider
Creates index entries for the specified resource URI. The specified
IIndexWriter is used to add the index entries to the index
store. A request to cancel the operation should be honored and
acknowledged by throwing OperationCanceledException.
createIndexEntries in interface IIndexProviderresourceURI - The resource URI that needs to be indexedindexWriter - the index writer used to add the index entries to the index
store.monitor - the progress monitorIndexExceptionprotected boolean shouldParseUsingContextResourceSet(org.eclipse.emf.common.util.URI resourceURI)
resourceURI - The resourceURI to be indexedprotected void createIndexEntriesByParsing(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI resourceURI,
IIndexWriter indexWriter,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws IndexException
IIndexWriter
to add the index entries to the index store. This method should throw a
AbortParsingException if parsing is not possible. This
will cause the resource to be loaded in order to create the index
entries. A request to cancel the operation should be honored and
acknowledged by throwing OperationCanceledException.resourceSet - the resource set to be used for parsing the resourceresourceURI - the resource uriindexWriter - the index writer to be used for adding the index entries to
the index storemonitor - the progress monitorIndexExceptionprotected void createIndexEntriesByLoading(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI resourceURI,
IIndexWriter indexWriter,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws IndexException
IIndexWriter to add the
index entries to the index store. A request to cancel the operation
should be honored and acknowledged by throwing
OperationCanceledException.resourceSet - the resource set to be used for loading the resourceresourceURI - the resource uriindexWriter - the index writer to be used for adding the index entries to
the index storemonitor - the progress monitorIndexExceptionprotected org.eclipse.emf.ecore.resource.ResourceSet getResourceSetForLoading(org.eclipse.emf.ecore.resource.ResourceSet defaultResourceSet)
defaultResourceSet - the resource set associated with the index contextprotected org.eclipse.emf.ecore.resource.ResourceSet getResourceSetForParsing(org.eclipse.emf.ecore.resource.ResourceSet defaultResourceSet)
defaultResourceSet - the resource set associated with the index contextpublic void dispose()
throws IndexException
IIndexProviderIIndexProvider.createIndexEntries(URI, IIndexWriter, IProgressMonitor)
method. Within this method a provider may release any resources and clear
any cache held by this provider.dispose in interface IIndexProviderIndexExceptionpublic void init(IndexContext context) throws IndexException
IIndexProviderinit in interface IIndexProvidercontext - the index contextIndexExceptionprotected final IndexContext getContext()
public static final java.lang.String getField(org.eclipse.emf.ecore.EAttribute eAttribute,
java.lang.String attributePrefix)
Get the computed field name for the specified attribute. This method is
use in the EObjectEntry class.
Note that this method is not intended to be called by clients. In some cases the field name returned by this method will not be consistent with other places in the index.
eAttribute - the specified EAttributeattributePrefix - the attribute prefix. This is either
IIndexProvider.ATT_PREFIX or
IIndexProvider.ATT_LC_PREFIXpublic static final java.lang.String getField(org.eclipse.emf.ecore.EReference eReference)
Get the computed field name for the specified reference. This method is
use in the EObjectEntry class.
Note that this method is not intended to be called by clients. In some case the field name returned by this method will not be consistent with other places in the index.
eReference - the specified EReference