public final class IndexContext
extends java.lang.Object
This class serves as the primary context for indexing platform to perform
queries against the index store. Instances of the this class are passed to
the various find methods of IIndexSearchManager
to control the
scope and the search results of the query. The class also provides convenient
methods to create some common contexts.
The class also provides some options that can be passed to the options map in the context. These options control aspects such as resolution of the objects which are part of the result set and searching unloaded resources.
Usage:
IndexContext context = IndexContext.createDefaultContext(new ResourceSetImpl()); context.getOptions().put(IndexContext.SEARCH_UNLOADED_RESOURCES, Boolean.TRUE); context.getOptions().put(IndexContext.RESOLVE_PROXIES, Boolean.FALSE);
IIndexSearchManager
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PROVIDE_INDEXED_DATA_FOR_PROXIES_AND_PARENTS
Option that controls if index information needs to be populated for
proxies and their parents (until the root) returned in the result set
|
static java.lang.String |
RESOLVE_PROXIES
Option that controls if proxies are to be resolved in the result set.
|
static java.lang.String |
SEARCH_DEPLOYED_RESOURCES
Option that controls if all resources deployed in plug-ins (and
registered on the com.ibm.xtools.emf.index.configurationEntries
extension point) are to be included in the search, in addition to any
that are included in the resource scope.
|
static java.lang.String |
SEARCH_IGNORING_CONTENT_TYPE
Ignore resource content types
|
static java.lang.String |
SEARCH_UNLOADED_RESOURCES
Option that controls if all unloaded resources are to be included in the
search, in addition to any that are already loaded in the resource set.
|
static java.lang.String |
STRICT_ECLASS_EQUALITY
Option to control the usage of the EClass argument when passed to the
find methods.
|
static java.lang.String |
SYNCHRONIZE_INDEX
Option to decide whether to synchronize the index during a query.
|
Constructor and Description |
---|
IndexContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Construct a resource set context that is independent of any scope.
|
IndexContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
java.util.Collection<?> scope)
Construct a resource scope context.
|
IndexContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
java.util.Collection<?> scope,
java.util.Collection<org.eclipse.core.runtime.content.IContentType> contentTypes)
Construct a resource scope context.
|
IndexContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
java.util.Collection<?> scope,
java.util.Map<java.lang.String,java.lang.Object> options)
Constructs the index context with preset option flags.
|
Modifier and Type | Method and Description |
---|---|
static IndexContext |
createDefaultContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Create a resource set context that is independent of any platform
resource.
|
static IndexContext |
createEResourceContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
java.util.Collection<?> resources)
Creates a resource collection context.
|
static IndexContext |
createEResourceContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.ecore.resource.Resource resource)
Creates a resource context.
|
static IndexContext |
createPlatformContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Creates a context covering the whole Eclipse platform (workspace and
resources deployed in plug-ins).
|
static IndexContext |
createPlatformContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
java.util.Collection<org.eclipse.core.runtime.content.IContentType> contentTypes)
Creates a context covering the whole Eclipse platform (workspace and
resources deployed in plug-ins) with the specified content types.
|
static IndexContext |
createPlatformResourceContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
java.util.Collection<?> resources)
Creates a platform resource collection context.
|
static IndexContext |
createPlatformResourceContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.core.resources.IResource resource)
Creates a platform resource context.
|
static IndexContext |
createWorkspaceContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Creates a workspace context.
|
static IndexContext |
createWorkspaceContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
java.util.Collection<org.eclipse.core.runtime.content.IContentType> contentTypes)
Creates a workspace context with the specified content types.
|
java.util.Collection<org.eclipse.emf.common.util.URI> |
getAllResourceURIs()
Gets all the resource URIs in the context.
|
java.util.Collection<org.eclipse.emf.common.util.URI> |
getLoadedResourceURIs()
Gets the loaded resource URIs within the context
|
java.util.Map<java.lang.String,java.lang.Object> |
getOptions()
Gets the search options.
|
IProxyData |
getProxyData()
Returns the interface that provides attribute and reference information
for proxies returned by the index store.
|
static org.eclipse.emf.common.util.URI |
getResource(org.eclipse.core.resources.IFile file)
Gets the resource uri given a platform
IFile |
org.eclipse.emf.ecore.resource.Resource |
getResource(org.eclipse.emf.common.util.URI uri,
boolean trimFragment)
Creates a resource for the specified uri.
|
org.eclipse.emf.ecore.resource.ResourceSet |
getResourceSet()
Gets the resource set associated with this context.
|
java.util.Collection<org.eclipse.emf.common.util.URI> |
getResourceURIs()
Gets the resource URIs within the context based on the
IndexContext.SEARCH_UNLOADED_RESOURCES and
IndexContext.SEARCH_DEPLOYED_RESOURCES options. |
org.eclipse.core.resources.IResource |
getWorkspaceResource(org.eclipse.emf.common.util.URI resourceURI)
Returns the corresponding workspace resource for the specified resource
uri
|
org.eclipse.core.resources.IResource[] |
getWorkspaceResources(java.util.Collection<org.eclipse.emf.common.util.URI> resourceURIs)
Returns the corresponding workspace resources for the specified list of
resource uris
|
static org.eclipse.emf.common.util.URI |
normalize(org.eclipse.emf.common.util.URI uri,
org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Normalizes the specified URI in the specified resource set.
|
public static final java.lang.String STRICT_ECLASS_EQUALITY
public static final java.lang.String SYNCHRONIZE_INDEX
public static final java.lang.String RESOLVE_PROXIES
public static final java.lang.String SEARCH_UNLOADED_RESOURCES
public static final java.lang.String SEARCH_DEPLOYED_RESOURCES
public static final java.lang.String SEARCH_IGNORING_CONTENT_TYPE
public static final java.lang.String PROVIDE_INDEXED_DATA_FOR_PROXIES_AND_PARENTS
public IndexContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
resourceSet
- The given resource set.public IndexContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, java.util.Collection<?> scope)
resourceSet
- The given resource set.scope
- The given scope. The scope can contain resources of type
IResource
or Resource
public IndexContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, java.util.Collection<?> scope, java.util.Map<java.lang.String,java.lang.Object> options)
resourceSet
- the resource setscope
- scope resourcesoptions
- the option flagspublic IndexContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, java.util.Collection<?> scope, java.util.Collection<org.eclipse.core.runtime.content.IContentType> contentTypes)
resourceSet
- The given resource set.scope
- The given scope. The scope can contain resources of type
IResource
or Resource
contentTypes
- The given set of content types. This is a list of
IContentType
spublic static IndexContext createDefaultContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
resourceSet
- The given resource set.public static IndexContext createEResourceContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.ecore.resource.Resource resource)
resourceSet
- The given resource set.resource
- The given resource.public static IndexContext createEResourceContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, java.util.Collection<?> resources)
resourceSet
- The given resource set.resources
- The given resource collection.public static IndexContext createWorkspaceContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
resourceSet
- The given resource set.public static IndexContext createWorkspaceContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, java.util.Collection<org.eclipse.core.runtime.content.IContentType> contentTypes)
resourceSet
- The given resource set.contentTypes
- The given set of content types. This is a list of
IContentType
spublic static IndexContext createPlatformResourceContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.core.resources.IResource resource)
resourceSet
- The given resource set.resource
- The platform resource.public static IndexContext createPlatformResourceContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, java.util.Collection<?> resources)
resourceSet
- The given resource set.resources
- The given platform resource collection.public static IndexContext createPlatformContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
resourceSet
- The given resource set.public static IndexContext createPlatformContext(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, java.util.Collection<org.eclipse.core.runtime.content.IContentType> contentTypes)
resourceSet
- The given resource set.contentTypes
- The given set of content types. This is a list of
IContentType
spublic org.eclipse.emf.ecore.resource.ResourceSet getResourceSet()
public java.util.Map<java.lang.String,java.lang.Object> getOptions()
public IProxyData getProxyData()
IProxyData
objectpublic java.util.Collection<org.eclipse.emf.common.util.URI> getAllResourceURIs()
URI
spublic static org.eclipse.emf.common.util.URI getResource(org.eclipse.core.resources.IFile file)
IFile
file
- the platform file objectpublic org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.common.util.URI uri, boolean trimFragment)
uri
- the input uritrimFragment
- flag to trim the fragmentnull
if
cannot create a resourcepublic org.eclipse.core.resources.IResource[] getWorkspaceResources(java.util.Collection<org.eclipse.emf.common.util.URI> resourceURIs)
resourceURIs
- the resource urisnull
if nonepublic org.eclipse.core.resources.IResource getWorkspaceResource(org.eclipse.emf.common.util.URI resourceURI)
resourceURI
- the resource urinull
if nonepublic java.util.Collection<org.eclipse.emf.common.util.URI> getLoadedResourceURIs()
URI
spublic java.util.Collection<org.eclipse.emf.common.util.URI> getResourceURIs()
IndexContext.SEARCH_UNLOADED_RESOURCES
and
IndexContext.SEARCH_DEPLOYED_RESOURCES
options. If the
IndexContext.SEARCH_UNLOADED_RESOURCES
is true then the
returned result will contain URIs for unloaded resources as well. If the
IndexContext.SEARCH_DEPLOYED_RESOURCES
is true then the
returned result will contain URIs for statically registered resource URIs
(loaded or unloaded) as well.URI
spublic static org.eclipse.emf.common.util.URI normalize(org.eclipse.emf.common.util.URI uri, org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
uri
- the URI to normalizeresourceSet
- the resource set defining the URI converter