public abstract class AdvancedIncQueryEngine extends IncQueryEngine
You can create a new, private, unmanaged AdvancedIncQueryEngine
instance using
createUnmanagedEngine(IncQueryScope)
. Additionally, you can access the advanced interface on any
IncQueryEngine
by from(IncQueryEngine)
.
While the default interface IncQueryEngine
, is suitable for most users, this advanced interface provides more
control over the engine. The most important added functionality is the following:
createUnmanagedEngine(IncQueryScope)
); a managed engine (obtained via IncQueryEngine.on(IncQueryScope)
) is
shared among clients and can not be disposed or wiped.
addLifecycleListener(IncQueryEngineLifecycleListener)
to learn when another client
has called the destructive methods dispose()
or wipe()
.
Constructor and Description |
---|
AdvancedIncQueryEngine() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addLifecycleListener(IncQueryEngineLifecycleListener listener)
Add an engine lifecycle listener to this engine instance.
|
abstract <Match extends IPatternMatch> |
addMatchUpdateListener(IncQueryMatcher<Match> matcher,
IMatchUpdateListener<? super Match> listener,
boolean fireNow)
Registers low-level callbacks for match appearance and disappearance on this pattern matcher.
|
abstract void |
addModelUpdateListener(IncQueryModelUpdateListener listener)
Add an model update event listener to this engine instance (that fires its callbacks according to its
notification level).
|
static AdvancedIncQueryEngine |
createUnmanagedEngine(IncQueryScope scope)
Creates a new unmanaged IncQuery engine to evaluate queries over a given scope specified by an
IncQueryScope . |
static AdvancedIncQueryEngine |
createUnmanagedEngine(org.eclipse.emf.common.notify.Notifier emfScopeRoot)
Deprecated.
use
createUnmanagedEngine(IncQueryScope) instead to evaluate queries on both EMF and non-EMF scopes. |
static AdvancedIncQueryEngine |
createUnmanagedEngine(org.eclipse.emf.common.notify.Notifier emfScopeRoot,
BaseIndexOptions options)
Deprecated.
use
createUnmanagedEngine(IncQueryScope) instead to evaluate queries on both EMF and non-EMF scopes. |
static AdvancedIncQueryEngine |
createUnmanagedEngine(org.eclipse.emf.common.notify.Notifier emfScopeRoot,
boolean wildcardMode)
Deprecated.
use
createUnmanagedEngine(IncQueryScope) instead to evaluate queries on both EMF and non-EMF scopes. |
static AdvancedIncQueryEngine |
createUnmanagedEngine(org.eclipse.emf.common.notify.Notifier emfScopeRoot,
boolean wildcardMode,
boolean dynamicEMFMode)
Deprecated.
use
createUnmanagedEngine(IncQueryScope) instead to evaluate queries on both EMF and non-EMF scopes. |
abstract void |
dispose()
Completely disconnects and dismantles the engine.
|
static AdvancedIncQueryEngine |
from(IncQueryEngine engine)
Provides access to a given existing engine through the advanced interface.
|
abstract <Matcher extends IncQueryMatcher<? extends IPatternMatch>> |
getMatcher(IQuerySpecification<Matcher> querySpecification,
QueryEvaluationHint optionalEvaluationHints)
Access a pattern matcher based on a
IQuerySpecification , overriding some of the default query evaluation hints. |
abstract IQueryBackend |
getQueryBackend(java.lang.Class<? extends IQueryBackend> backendClass)
Provides access to the selected query backend component of the IncQuery engine.
|
abstract boolean |
isManaged()
Indicates whether the engine is managed, i.e.
|
abstract boolean |
isTainted()
Indicates whether the engine is in a tainted, inconsistent state due to some internal errors.
|
abstract void |
prepareGroup(IQueryGroup queryGroup,
QueryEvaluationHint optionalEvaluationHints)
Initializes matchers for a group of patterns as one step (optionally overriding some of the default query evaluation hints).
|
abstract void |
removeLifecycleListener(IncQueryEngineLifecycleListener listener)
Remove an existing lifecycle listener from this engine instance.
|
abstract <Match extends IPatternMatch> |
removeMatchUpdateListener(IncQueryMatcher<Match> matcher,
IMatchUpdateListener<? super Match> listener)
Remove an existing match update event listener to this engine instance.
|
abstract void |
removeModelUpdateListener(IncQueryModelUpdateListener listener)
Remove an existing model update event listener to this engine instance.
|
abstract void |
wipe()
Discards any pattern matcher caches and forgets known patterns.
|
getBaseIndex, getCurrentMatchers, getEMFRoot, getExistingMatcher, getMatcher, getMatcher, getRegisteredQuerySpecifications, getScope, on, on
@Deprecated public static AdvancedIncQueryEngine createUnmanagedEngine(org.eclipse.emf.common.notify.Notifier emfScopeRoot) throws IncQueryException
createUnmanagedEngine(IncQueryScope)
instead to evaluate queries on both EMF and non-EMF scopes.
Client is responsible for the lifecycle of the returned engine, hence the usage of the advanced interface
AdvancedIncQueryEngine
.
The scope of pattern matching will be the given EMF model root and below (see FAQ for more precise definition). The match set of any patterns will be incrementally refreshed upon updates from this scope.
emfScopeRoot
- the root of the EMF containment hierarchy where this engine should operate. Recommended: Resource or
ResourceSet.IncQueryException
for performance tuning and dynamic EMF options.
@Deprecated public static AdvancedIncQueryEngine createUnmanagedEngine(org.eclipse.emf.common.notify.Notifier emfScopeRoot, boolean wildcardMode) throws IncQueryException
createUnmanagedEngine(IncQueryScope)
instead to evaluate queries on both EMF and non-EMF scopes.
Client is responsible for the lifecycle of the returned engine, hence the usage of the advanced interface
AdvancedIncQueryEngine
.
The scope of pattern matching will be the given EMF model root and below (see FAQ for more precise definition). The match set of any patterns will be incrementally refreshed upon updates from this scope.
emfScopeRoot
- the root of the EMF containment hierarchy where this engine should operate. Recommended: Resource or
ResourceSet.wildcardMode
- specifies whether the base index should be built in wildcard mode. See BaseIndexOptions
for
the explanation of wildcard mode. Defaults to false.IncQueryException
@Deprecated public static AdvancedIncQueryEngine createUnmanagedEngine(org.eclipse.emf.common.notify.Notifier emfScopeRoot, boolean wildcardMode, boolean dynamicEMFMode) throws IncQueryException
createUnmanagedEngine(IncQueryScope)
instead to evaluate queries on both EMF and non-EMF scopes.
Client is responsible for the lifecycle of the returned engine, hence the usage of the advanced interface
AdvancedIncQueryEngine
.
The scope of pattern matching will be the given EMF model root and below (see FAQ for more precise definition). The match set of any patterns will be incrementally refreshed upon updates from this scope.
emfScopeRoot
- the root of the EMF containment hierarchy where this engine should operate. Recommended: Resource or
ResourceSet.wildcardMode
- specifies whether the base index should be built in wildcard mode. See BaseIndexOptions
for
the explanation of wildcard mode. Defaults to false.dynamicEMFMode
- specifies whether the base index should be built in dynamic EMF mode. See BaseIndexOptions
for
the explanation of dynamic EMF mode. Defaults to false.IncQueryException
@Deprecated public static AdvancedIncQueryEngine createUnmanagedEngine(org.eclipse.emf.common.notify.Notifier emfScopeRoot, BaseIndexOptions options) throws IncQueryException
createUnmanagedEngine(IncQueryScope)
instead to evaluate queries on both EMF and non-EMF scopes.
Client is responsible for the lifecycle of the returned engine, hence the usage of the advanced interface
AdvancedIncQueryEngine
.
The scope of pattern matching will be the given EMF model root and below (see FAQ for more precise definition). The match set of any patterns will be incrementally refreshed upon updates from this scope.
emfScopeRoot
- the root of the EMF containment hierarchy where this engine should operate. Recommended: Resource or
ResourceSet.options
- specifies how the base index is built, including wildcard mode (defaults to false) and dynamic EMF
mode (defaults to false). See BaseIndexOptions
for the explanation of wildcard mode and
dynamic EMF mode.IncQueryException
public static AdvancedIncQueryEngine createUnmanagedEngine(IncQueryScope scope) throws IncQueryException
IncQueryScope
.
Repeated invocations will return different instances, so other clients are unable to independently access and influence the returned engine. Note that unmanaged engines do not benefit from some performance improvements that stem from sharing incrementally maintained indices and caches between multiple clients using the same managed engine instance.
Client is responsible for the lifecycle of the returned engine, hence the usage of the advanced interface
AdvancedIncQueryEngine
.
The match set of any patterns will be incrementally refreshed upon updates from this scope.
scope
- the scope of query evaluation; the definition of the set of model elements that this engine is operates on.
Provide e.g. a EMFScope
for evaluating queries on an EMF model.IncQueryException
public static AdvancedIncQueryEngine from(IncQueryEngine engine)
Caveat: if the referenced engine is managed (i.e. created via IncQueryEngine.on(IncQueryScope)
), the advanced
methods dispose()
and wipe()
will not be allowed.
engine
- the engine to access using the advanced interfacepublic abstract void addLifecycleListener(IncQueryEngineLifecycleListener listener)
listener
- the IncQueryEngineLifecycleListener
that should listen to lifecycle events from this enginepublic abstract void removeLifecycleListener(IncQueryEngineLifecycleListener listener)
listener
- the IncQueryEngineLifecycleListener
that should not listen to lifecycle events from this
engine anymorepublic abstract void addModelUpdateListener(IncQueryModelUpdateListener listener)
listener
- the IncQueryModelUpdateListener
that should listen to model update events from this engine.public abstract void removeModelUpdateListener(IncQueryModelUpdateListener listener)
listener
- the IncQueryModelUpdateListener
that should not listen to model update events from this engine
anymorepublic abstract <Match extends IPatternMatch> void addMatchUpdateListener(IncQueryMatcher<Match> matcher, IMatchUpdateListener<? super Match> listener, boolean fireNow)
Caution: This is a low-level callback that is invoked when the pattern matcher is not necessarily in a consistent state yet. Importantly, no model modification permitted during the callback. Most users should use the databinding support (org.eclipse.incquery.databinding.runtime.api.IncQueryObservables) or the event-driven API (org.eclipse.incquery.runtime.evm.api.EventDrivenVM) instead.
Performance note: expected to be much more efficient than polling at #addCallbackAfterUpdates(Runnable)
,
but prone to "signal hazards", e.g. spurious match appearances that will disappear immediately afterwards.
The callback can be unregistered via #removeCallbackOnMatchUpdate(IMatchUpdateListener)
.
fireNow
- if true, appearCallback will be immediately invoked on all current matches as a one-time effect. See
also IncQueryMatcher.forEachMatch(IMatchProcessor)
.listener
- the listener that will be notified of each new match that appears or disappears, starting from now.matcher
- the IncQueryMatcher
for which this listener should be activepublic abstract <Match extends IPatternMatch> void removeMatchUpdateListener(IncQueryMatcher<Match> matcher, IMatchUpdateListener<? super Match> listener)
matcher
- the IncQueryMatcher
for which this listener should not be active anymorelistener
- the IMatchUpdateListener
that should not receive the callbacks anymorepublic abstract <Matcher extends IncQueryMatcher<? extends IPatternMatch>> Matcher getMatcher(IQuerySpecification<Matcher> querySpecification, QueryEvaluationHint optionalEvaluationHints) throws IncQueryException
IQuerySpecification
, overriding some of the default query evaluation hints.
Multiple calls will return the same matcher.
Hints are only effective the first time a matcher is created.
querySpecification
- a IQuerySpecification
that describes an IncQuery queryoptionalEvaluationHints
- additional / overriding options on query evaluation; passing null means default options associated with the queryIncQueryException
- if the matcher could not be initializedpublic abstract void prepareGroup(IQueryGroup queryGroup, QueryEvaluationHint optionalEvaluationHints) throws IncQueryException
This preparation step has the advantage that it prepares pattern matchers for an arbitrary number of patterns in a single-pass traversal of the model. This is typically more efficient than traversing the model each time an individual pattern matcher is initialized on demand. The performance benefit only manifests itself if the engine is not in wildcard mode.
queryGroup
- a IQueryGroup
identifying a set of IncQuery queriesoptionalEvaluationHints
- additional / overriding options on query evaluation; passing null means default options associated with each queryIncQueryException
- if there was an error in preparing the enginepublic abstract boolean isManaged()
IncQueryEngine.on(IncQueryScope)
.
If the engine is managed, there may be other clients using it, as all calls to
IncQueryEngine.on(IncQueryScope)
return the same managed engine instance for a given scope root. Therefore the
destructive methods wipe()
and dispose()
are not allowed.
On the other hand, if the engine is unmanaged (i.e. a private instance created using
createUnmanagedEngine(IncQueryScope)
), then wipe()
and dispose()
can be called. If you
explicitly share a private, unmanaged engine between multiple sites, register a callback using
addLifecycleListener(IncQueryEngineLifecycleListener)
to learn when another client has called these
destructive methods.
public abstract boolean isTainted()
The engine is in a tainted state if any of its internal processes report back a fatal error. The
IncQueryEngineLifecycleListener
interface provides a callback method for entering the tainted state.
public abstract void wipe()
Matcher objects will continue to return stale results. If no references are retained to the matchers, they can eventually be GC'ed.
Disallowed if the engine is managed (see isManaged()
), as there may be other clients using it.
If you explicitly share a private, unmanaged engine between multiple sites, register a callback using
addLifecycleListener(IncQueryEngineLifecycleListener)
to learn when another client has called this
destructive method.
java.lang.UnsupportedOperationException
- if engine is managedpublic abstract void dispose()
Matcher objects will continue to return stale results. If no references are retained to the matchers or the engine, they can eventually be GC'ed, and they won't block the EMF model from being GC'ed anymore.
The base indexer (see IncQueryEngine.getBaseIndex()
) built on the model will be disposed alongside the engine, unless
the user has manually added listeners on the base index that were not removed yet.
Disallowed if the engine is managed (see isManaged()
), as there may be other clients using it.
If you explicitly share a private, unmanaged engine between multiple sites, register a callback using
addLifecycleListener(IncQueryEngineLifecycleListener)
to learn when another client has called this
destructive method.
java.lang.UnsupportedOperationException
- if engine is managedpublic abstract IQueryBackend getQueryBackend(java.lang.Class<? extends IQueryBackend> backendClass) throws IncQueryException
IncQueryException