org.eclipse.emf.henshin.interpreter.util
Class InterpreterUtil

java.lang.Object
  extended by org.eclipse.emf.henshin.interpreter.util.InterpreterUtil

public class InterpreterUtil
extends Object

Common utility methods for the Henshin interpreter.


Constructor Summary
InterpreterUtil()
           
 
Method Summary
static boolean applyToResource(Assignment assignment, Engine engine, Resource resource, ApplicationMonitor monitor)
          Apply a unit to the contents of a resource.
static boolean applyToResource(Unit unit, Engine engine, Resource resource)
          Apply a unit to the contents of a resource.
static boolean areIsomorphic(EGraph graph1, EGraph graph2)
          Check whether two EGraphs are isomorphic.
static boolean areIsomorphic(Resource resource1, Resource resource2)
          Check whether the contents of two resources are isomorphic.
static int countEdges(EGraph graph)
          Count the number of edges/links in a graph.
static void executeOrDie(UnitApplication application)
          Execute the given unit application and throws an AssertionError if it could not be successfully applied (if UnitApplication.execute(ApplicationMonitor) returns false).
static List<Match> findAllMatches(Engine engine, Module module, EGraph graph)
          Find all matches of all rules in a module.
static List<Match> findAllMatches(Engine engine, Rule rule, EGraph graph, Match partialMatch)
          Find all matches for a rule.
static PartialMatchReport findAndReportMaximalPartialMatches(Engine engine, Module module, EGraph graph)
          This method is similar to the method findMasimalPartialMatches but outputs a report instead of a list of matches.
static List<Match> findMaximalPartialMatches(Engine engine, Module module, EGraph graph)
          This method calculates a complete match for rules of the given model transformation with a given model.
static String objectToString(Object object)
          Get a string representation of an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterpreterUtil

public InterpreterUtil()
Method Detail

findAllMatches

public static List<Match> findAllMatches(Engine engine,
                                         Rule rule,
                                         EGraph graph,
                                         Match partialMatch)
Find all matches for a rule.

Parameters:
engine - Engine.
rule - Rule to be matched.
graph - Target graph.
partialMatch - Partial match or null.
Returns:
List of found matches.

findAllMatches

public static List<Match> findAllMatches(Engine engine,
                                         Module module,
                                         EGraph graph)
Find all matches of all rules in a module. This does not consider submodules.

Parameters:
engine - Engine to be used.
module - Module to be used.
graph - Target graph.
Returns:
List of matches.

findMaximalPartialMatches

public static List<Match> findMaximalPartialMatches(Engine engine,
                                                    Module module,
                                                    EGraph graph)
This method calculates a complete match for rules of the given model transformation with a given model. If a complete match does not exist, the method calculates a partial match, if it exists. For that a rule is reduced till a complete match for a reduced rule is found. For reduced rules having the same size, all matches are searched. If a match is found for a reduced rule, this rule is not reduced further.

Parameters:
engine - Engine to be used.
module - Module to be used.
graph - Target graph.
Returns:
List of matches (both complete and partial per rule)

findAndReportMaximalPartialMatches

public static PartialMatchReport findAndReportMaximalPartialMatches(Engine engine,
                                                                    Module module,
                                                                    EGraph graph)
This method is similar to the method findMasimalPartialMatches but outputs a report instead of a list of matches. This method calculates a complete match for rules of the given model transformation with a given model. If a complete match does not exist, the method calculates a partial match, if it exists. For that a rule is reduced till a complete match for a reduced rule is found. For reduced rules having the same size, all matches are searched. If a match is found for a reduced rule, this rule is not reduced further. If partial matches are found, then a report object is created based on the list of found partial matches.

Parameters:
engine - Engine to be used.
module - Module to be used.
graph - Target graph.
Returns:
List of matches (both complete and partial per rule)

executeOrDie

public static void executeOrDie(UnitApplication application)
Execute the given unit application and throws an AssertionError if it could not be successfully applied (if UnitApplication.execute(ApplicationMonitor) returns false). This is just a convenience method.

Parameters:
application - A unit application.

applyToResource

public static boolean applyToResource(Unit unit,
                                      Engine engine,
                                      Resource resource)
Apply a unit to the contents of a resource. This automatically creates an EGraph and updates the contents of the resource.

Parameters:
unit - Unit to be applied.
engine - Engine to be used.
resource - Resource containing the model to be transformed.
Returns:
true if the unit was successfully applied.

applyToResource

public static boolean applyToResource(Assignment assignment,
                                      Engine engine,
                                      Resource resource,
                                      ApplicationMonitor monitor)
Apply a unit to the contents of a resource. This automatically creates an EGraph and updates the contents of the resource.

Parameters:
assignment - Assignment to be used.
engine - Engine to be used.
resource - Resource containing the model to be transformed.
Returns:
true if the unit was successfully applied.

areIsomorphic

public static boolean areIsomorphic(EGraph graph1,
                                    EGraph graph2)
Check whether two EGraphs are isomorphic.

Parameters:
graph1 - First graph.
graph2 - Second graph.
Returns:
true if they are isomorphic.

areIsomorphic

public static boolean areIsomorphic(Resource resource1,
                                    Resource resource2)
Check whether the contents of two resources are isomorphic.

Parameters:
resource1 - First resource.
resource2 - Second resource.
Returns:
true if they are isomorphic.

countEdges

public static int countEdges(EGraph graph)
Count the number of edges/links in a graph.

Parameters:
graph - An EGraph
Returns:
Number of edges/links in that graph.

objectToString

public static String objectToString(Object object)
Get a string representation of an object.

Parameters:
object - An object.
Returns:
A readable string representation.