org.infai.emo.matcher.action
Class ModelComparator

java.lang.Object
  extended by org.infai.emo.matcher.action.ModelComparator

public class ModelComparator
extends java.lang.Object

Class used for comparing the two given models.
The sequence of the comparators is defined in this class.
This class offers methods for initializing models and comparing them.

Version:
1.1.3
Author:
Stanley Hillner

Field Summary
private  boolean crossProduct
          True if the matching between the models shall base on a full cross product between both models.
private  java.util.Vector<Matching> detailedMatchings
          This vector stores all the atomic matchings between both models.
private  Model leftModel
          The first model that the user has chosen to compare.
private  Model metaModel
          The metaModel that describes the elements and the structure of the both models.
private  Model rightModel
          The second model that the user has chosen to compare.
private  boolean useTreePosition
          This flag indicates whether to use the elements positions in the model-trees for the comparison or not.
private  java.util.Hashtable<java.lang.String,java.lang.Double> weightings
          This HashTable contains the weightings for the individual comparators.
 
Constructor Summary
ModelComparator(java.util.Hashtable<java.lang.String,java.lang.Double> weightings, boolean crossProduct, boolean useTreePosition)
          Produces a new ModelComparator with the given weightings for the atomic comparators.
 
Method Summary
 Matching compareTo(Model model1, Model model2)
          This method compares the two given models using the following comparators:
MetaClassComparator AttributeComparator ReferenceComparator ContainerComparator ContentsComparator individually initialized GenericFeatureComparator(s) the PositionComparator (for critical matching-values only)

 java.util.Vector<Matching> getDetailedMatchings()
           
 Model getLeftModel()
           
 Model getMetaModel()
           
 Model getRightModel()
           
 java.util.Hashtable<java.lang.String,java.lang.Double> getWeightings()
           
private  Model initModel(org.eclipse.emf.ecore.EObject o)
          Create a model out of the given EObject.
private  Model initModel(java.lang.String path)
          Create a model out of the given path.
 void initModels(org.eclipse.emf.ecore.EObject leftEObject, org.eclipse.emf.ecore.EObject rightEObject)
          Initializes the models from their parent EObjects.
 void initModels(java.lang.String leftModelPath, java.lang.String rightModelPath, java.lang.String metaModelPath)
          Initializes the models from their paths.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

leftModel

private Model leftModel
The first model that the user has chosen to compare.

See Also:
Model

rightModel

private Model rightModel
The second model that the user has chosen to compare.

See Also:
Model

metaModel

private Model metaModel
The metaModel that describes the elements and the structure of the both models.

See Also:
Model

detailedMatchings

private java.util.Vector<Matching> detailedMatchings
This vector stores all the atomic matchings between both models.
For example it will include the MetaClassMatching, the AttributeMatching, the ContainerMatching and so far.

See Also:
Vector

weightings

private java.util.Hashtable<java.lang.String,java.lang.Double> weightings
This HashTable contains the weightings for the individual comparators.
The key is the comparator-name (case-sensitive).
The value is the weighting of the comparator as a value between 0 and 1.0 while 1.0 means 100%.


crossProduct

private boolean crossProduct
True if the matching between the models shall base on a full cross product between both models.
If this flag is set to true a full comparison between both models will take place (each element of the left model will be compared with each element of the right model).

See Also:
Hashtable

useTreePosition

private boolean useTreePosition
This flag indicates whether to use the elements positions in the model-trees for the comparison or not.
If the flag is set to true the reflection on the elements positions will take place as the last comparison criterion.

Constructor Detail

ModelComparator

public ModelComparator(java.util.Hashtable<java.lang.String,java.lang.Double> weightings,
                       boolean crossProduct,
                       boolean useTreePosition)
Produces a new ModelComparator with the given weightings for the atomic comparators.

Note: If you only use the standard-comparators and your weightings are 1.0 for each comparator then set weightings to null.

Parameters:
weightings - a Hashtable with the weightings for each comparator.
crossProduct - whether to make a full comparison between both models or not.
useTreePosition - whether to take the positions of the elements into account or not.
See Also:
weightings, crossProduct, useTreePosition
Method Detail

initModels

public void initModels(java.lang.String leftModelPath,
                       java.lang.String rightModelPath,
                       java.lang.String metaModelPath)
Initializes the models from their paths.

Parameters:
leftModelPath - path to the first model.
rightModelPath - path to the second model.
metaModelPath - path to the meta model, that can also be null or an empty String.

initModels

public void initModels(org.eclipse.emf.ecore.EObject leftEObject,
                       org.eclipse.emf.ecore.EObject rightEObject)
Initializes the models from their parent EObjects.

Parameters:
leftEObject - left element.
rightEObject - right element.

initModel

private Model initModel(java.lang.String path)
Create a model out of the given path.

Parameters:
path - the path that resolves the model file.
Returns:
the model created from the file.

initModel

private Model initModel(org.eclipse.emf.ecore.EObject o)
Create a model out of the given EObject.

Parameters:
o - the parent object.
Returns:
the model.

compareTo

public Matching compareTo(Model model1,
                          Model model2)
This method compares the two given models using the following comparators:
  1. MetaClassComparator
  2. AttributeComparator
  3. ReferenceComparator
  4. ContainerComparator
  5. ContentsComparator
  6. individually initialized GenericFeatureComparator(s)
  7. the PositionComparator (for critical matching-values only)


    1. Parameters:
      model1 - the left model.
      model2 - the right model.
      Returns:
      a matching between the two models.
      See Also:
      leftModel, rightModel, Matching

getLeftModel

public Model getLeftModel()
Returns:
the leftModel.
See Also:
leftModel

getRightModel

public Model getRightModel()
Returns:
the rightModel.
See Also:
rightModel

getMetaModel

public Model getMetaModel()
Returns:
the metaModel.
See Also:
metaModel

getDetailedMatchings

public java.util.Vector<Matching> getDetailedMatchings()
Returns:
a vector containing all the atomic matchings.
See Also:
detailedMatchings

getWeightings

public java.util.Hashtable<java.lang.String,java.lang.Double> getWeightings()
Returns:
the weightings for the comparators
See Also:
weightings