org.eclipse.emf.henshin.interpreter.impl
Class EngineImpl

java.lang.Object
  extended by org.eclipse.emf.henshin.interpreter.impl.EngineImpl
All Implemented Interfaces:
Engine

public class EngineImpl
extends Object
implements Engine

Default Engine implementation.


Field Summary
protected  Map<Graph,org.eclipse.emf.henshin.interpreter.impl.EngineImpl.MatchingOptions> graphOptions
          Cached graph options.
protected  boolean inverseMatchingOrder
          Whether to use inverse matching order.
protected  Map<String,Object> options
          Options to be used.
protected  Map<Rule,org.eclipse.emf.henshin.interpreter.info.RuleInfo> ruleInfos
          Cached information lookup map for each rule.
protected  EContentAdapter ruleListener
          Listen for rule changes.
protected  ScriptEngineWrapper scriptEngine
          Script engine used to compute Java expressions in attributes.
protected  boolean sortVariables
          Whether to sort variables.
protected  ExecutorService workerPool
          Worker thread pool.
 
Fields inherited from interface org.eclipse.emf.henshin.interpreter.Engine
OPTION_CHECK_DANGLING, OPTION_DETERMINISTIC, OPTION_INJECTIVE_MATCHING, OPTION_INVERSE_MATCHING_ORDER, OPTION_SORT_VARIABLES, OPTION_WORKER_THREADS
 
Constructor Summary
EngineImpl()
          Default constructor.
 
Method Summary
 void clearCache()
          Clear the cache of this engine.
 Change createChange(Rule rule, EGraph graph, Match completeMatch, Match resultMatch)
          Create an Change for applying a rule.
 void createChanges(Rule rule, EGraph graph, Match completeMatch, Match resultMatch, Change.CompoundChange complexChange)
          Recursively create the changes and result matches.
 org.eclipse.emf.henshin.interpreter.matching.constraints.UnaryConstraint createUserConstraints(Attribute attribute)
          Create user constraints for an attribute.
 org.eclipse.emf.henshin.interpreter.matching.constraints.BinaryConstraint createUserConstraints(Edge edge)
          Create user constraints for an edge.
 org.eclipse.emf.henshin.interpreter.matching.constraints.UnaryConstraint createUserConstraints(Node node)
          Create user constraints for a node.
 Object evalAttributeExpression(Attribute attribute, Rule rule)
          Evaluates a given attribute expression using the JavaScript engine.
 Iterable<Match> findMatches(Rule rule, EGraph graph, Match partialMatch)
          Find matches for a Rule in an EGraph.
protected  org.eclipse.emf.henshin.interpreter.impl.EngineImpl.MatchingOptions getGraphOptions(Graph graph)
          Get the options for a specific rule graph.
 Map<String,Object> getOptions()
          Get or set the options for this engine.
protected  org.eclipse.emf.henshin.interpreter.info.RuleInfo getRuleInfo(Rule rule)
          Get the cached rule info for a given rule.
 ScriptEngine getScriptEngine()
          Get the used script engine.
 void shutdown()
          Shutdown this engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

options

protected final Map<String,Object> options
Options to be used.


scriptEngine

protected final ScriptEngineWrapper scriptEngine
Script engine used to compute Java expressions in attributes.


ruleInfos

protected final Map<Rule,org.eclipse.emf.henshin.interpreter.info.RuleInfo> ruleInfos
Cached information lookup map for each rule.


graphOptions

protected final Map<Graph,org.eclipse.emf.henshin.interpreter.impl.EngineImpl.MatchingOptions> graphOptions
Cached graph options.


ruleListener

protected final EContentAdapter ruleListener
Listen for rule changes.


sortVariables

protected boolean sortVariables
Whether to sort variables.


inverseMatchingOrder

protected boolean inverseMatchingOrder
Whether to use inverse matching order.


workerPool

protected ExecutorService workerPool
Worker thread pool.

Constructor Detail

EngineImpl

public EngineImpl()
Default constructor.

Method Detail

findMatches

public Iterable<Match> findMatches(Rule rule,
                                   EGraph graph,
                                   Match partialMatch)
Description copied from interface: Engine
Find matches for a Rule in an EGraph.

Specified by:
findMatches in interface Engine
Parameters:
rule - Rule to be matched.
graph - Graph where the match should be found.
partialMatch - Partial match (can be empty or null).
Returns:
An iterable list of matches.

getRuleInfo

protected org.eclipse.emf.henshin.interpreter.info.RuleInfo getRuleInfo(Rule rule)
Get the cached rule info for a given rule.

Parameters:
rule - Rule.
Returns:
The (cached) rule info.

clearCache

public void clearCache()
Clear the cache of this engine.


createChange

public Change createChange(Rule rule,
                           EGraph graph,
                           Match completeMatch,
                           Match resultMatch)
Description copied from interface: Engine
Create an Change for applying a rule.

Specified by:
createChange in interface Engine
Parameters:
rule - Rule to be applied.
graph - Graph where the rule should be applied.
completeMatch - A complete match for the rule in the graph.
resultMatch - This result match will be initialized by the engine!
Returns:
An Change object that can be used to apply the rule

createChanges

public void createChanges(Rule rule,
                          EGraph graph,
                          Match completeMatch,
                          Match resultMatch,
                          Change.CompoundChange complexChange)
Recursively create the changes and result matches.

Parameters:
rule - Rule to be applied.
graph - Host graph.
completeMatch - The complete match.
resultMatch - The result match.
complexChange - The final complex change.

evalAttributeExpression

public Object evalAttributeExpression(Attribute attribute,
                                      Rule rule)
Evaluates a given attribute expression using the JavaScript engine.

Parameters:
attribute - Attribute to be interpreted.
Returns:
The value.

getOptions

public Map<String,Object> getOptions()
Description copied from interface: Engine
Get or set the options for this engine.

Specified by:
getOptions in interface Engine
Returns:
Options map.

getGraphOptions

protected org.eclipse.emf.henshin.interpreter.impl.EngineImpl.MatchingOptions getGraphOptions(Graph graph)
Get the options for a specific rule graph. The graph should be either the LHS or a nested condition.

Parameters:
graph - The graph.
Returns:
The cached options.

getScriptEngine

public ScriptEngine getScriptEngine()
Description copied from interface: Engine
Get the used script engine.

Specified by:
getScriptEngine in interface Engine
Returns:
Script engine.

shutdown

public void shutdown()
Description copied from interface: Engine
Shutdown this engine.

Specified by:
shutdown in interface Engine

createUserConstraints

public org.eclipse.emf.henshin.interpreter.matching.constraints.UnaryConstraint createUserConstraints(Node node)
Create user constraints for a node.

Parameters:
node - A node.
Returns:
The created user constraints.

createUserConstraints

public org.eclipse.emf.henshin.interpreter.matching.constraints.BinaryConstraint createUserConstraints(Edge edge)
Create user constraints for an edge.

Parameters:
edge - An edge.
Returns:
The created user constraint.

createUserConstraints

public org.eclipse.emf.henshin.interpreter.matching.constraints.UnaryConstraint createUserConstraints(Attribute attribute)
Create user constraints for an attribute.

Parameters:
attribute - An attribute.
Returns:
The created user constraint.