EDU.utwente.CoCompose.translate
Class DetermineFormsVisitor

java.lang.Object
  |
  +--EDU.utwente.CoCompose.lang.ModelVisitor
        |
        +--EDU.utwente.CoCompose.translate.DetermineFormsVisitor
All Implemented Interfaces:
java.lang.Runnable

public class DetermineFormsVisitor
extends ModelVisitor

Determines the concept forms of all concepts in a model.

Version:
0.1.18, 22 November 2003
Author:
Dennis Wagelaar

Field Summary
protected  FormConstraintsVisitor constraintCheck
          The form checking visitor needed to check constraints
protected  Model thisModel
          The model on which this visitor is applied.
 
Fields inherited from class EDU.utwente.CoCompose.lang.ModelVisitor
log
 
Constructor Summary
DetermineFormsVisitor()
          Constructs a ModelVisitor.
 
Method Summary
protected  void applyHeuristics()
          Applies the concept form heuristics defined in the model to eliminate permutations.
protected  java.util.Hashtable comparePermutations(java.util.Hashtable perm1, java.util.Hashtable perm2)
          Compares two permutations and returns the one that should be deleted according to the concept form heuristics.
protected  void createPermutations(Concept concept, java.util.Set forms)
          Creates new concept forms permutations from Concept |-> form.
 void createResultingModels()
          Creates the resulting models using the valid permutations of concept forms.
protected  void eliminatePermutations()
          Eliminates permutations that violate concept form constraints.
protected  java.util.Set getConceptForms(AbstractConcept concept)
          Gets the set of concept forms for a concept.
protected  java.util.Set getFormPermutations()
          Gets the concept form permutations for the entire model.
 java.util.Collection getResultingModels()
          Retrieves the resulting models using the valid permutations of concept forms.
protected  void setConceptForms(AbstractConcept concept, java.util.Set forms)
          Sets the set of concept forms for a concept.
protected  void setConceptForms(Concept concept, java.util.Set forms)
          Sets the set of concept forms for a concept and generates permutations.
protected  void setFormPermutations(java.util.Set permutations)
          Sets the concept form permutations for the entire model.
 void visitCompositeRole(CompositeRole role)
          Gets the possible concept forms for which the composite will translate into the model's target language.
PRE: The model and composite must be defined for this composite role.
 void visitConcept(Concept concept)
          Determines the possible concept forms for this concept using the target language of the model.
PRE: The model must be defined for this concept.
 void visitModel(Model model)
          Determines the concept forms for each concept in the model.
 
Methods inherited from class EDU.utwente.CoCompose.lang.ModelVisitor
getUpdate, run, setErrorReporter, setLogger, setUpdate, startModel, visitAbstractConcept, visitComposite, visitCompositePartConcept, visitConstrainedConcept, visitImplementation, visitImplementationGenerator, visitImplementationRolePart, visitLink, visitPublishedConcept, visitSolutionPattern, visitSolutionRole
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

thisModel

protected Model thisModel
The model on which this visitor is applied.

constraintCheck

protected FormConstraintsVisitor constraintCheck
The form checking visitor needed to check constraints
Constructor Detail

DetermineFormsVisitor

public DetermineFormsVisitor()
Constructs a ModelVisitor.
Method Detail

getConceptForms

protected java.util.Set getConceptForms(AbstractConcept concept)
Gets the set of concept forms for a concept.
Parameters:
concept - The concept to get the forms for.
Returns:
The set of concept forms.

setConceptForms

protected void setConceptForms(AbstractConcept concept,
                               java.util.Set forms)
Sets the set of concept forms for a concept.
Parameters:
concept - - the concept to set the forms for.
forms - - the Set of concept forms.

setConceptForms

protected void setConceptForms(Concept concept,
                               java.util.Set forms)
                        throws CoComposeException
Sets the set of concept forms for a concept and generates permutations.
Parameters:
concept - - the concept to set the forms for.
forms - - the Set of concept forms.
Throws:
CoComposeException - - if no permutations left afterwards.

getFormPermutations

protected java.util.Set getFormPermutations()
Gets the concept form permutations for the entire model.
Returns:
The concept form permutations: Set String>.

setFormPermutations

protected void setFormPermutations(java.util.Set permutations)
Sets the concept form permutations for the entire model.
Parameters:
permutations - - the concept form permutations: Set String>.

createPermutations

protected void createPermutations(Concept concept,
                                  java.util.Set forms)
                           throws CoComposeException
Creates new concept forms permutations from Concept |-> form.
Parameters:
concept - - the concept to create permutations for.
forms - - the Set of concept forms to create permutations for.
Throws:
CoComposeException - - if no permutation is left afterwards.

eliminatePermutations

protected void eliminatePermutations()
                              throws CoComposeException
Eliminates permutations that violate concept form constraints.
Throws:
CoComposeException - if all permutations got eliminated.

applyHeuristics

protected void applyHeuristics()
Applies the concept form heuristics defined in the model to eliminate permutations.

comparePermutations

protected java.util.Hashtable comparePermutations(java.util.Hashtable perm1,
                                                  java.util.Hashtable perm2)
Compares two permutations and returns the one that should be deleted according to the concept form heuristics. This only applies if the permutations differ in only one concept form, otherwise the method returns null.
Parameters:
perm1 - - the first permutation Hashtable String> to compare.
perm2 - - the second permutation Hashtable String> to compare.
Returns:
the permutation Hashtable String> to delete (first or second), or null.

createResultingModels

public void createResultingModels()
Creates the resulting models using the valid permutations of concept forms.

getResultingModels

public java.util.Collection getResultingModels()
Retrieves the resulting models using the valid permutations of concept forms.
Returns:
the resulting set of models: Set.

visitModel

public void visitModel(Model model)
                throws CoComposeException
Determines the concept forms for each concept in the model.
Overrides:
visitModel in class ModelVisitor
Parameters:
model - - the model to visit.
Throws:
CoComposeException - - if one of the model's constraints are not fulfilled or if not all concept forms could be determined.

visitConcept

public void visitConcept(Concept concept)
                  throws CoComposeException
Determines the possible concept forms for this concept using the target language of the model.
PRE: The model must be defined for this concept.
Overrides:
visitConcept in class ModelVisitor
Parameters:
concept - - the concept to determine the forms for.
Throws:
CoComposeException - - if the concept forms could not be determined.

visitCompositeRole

public void visitCompositeRole(CompositeRole role)
                        throws CoComposeException
Gets the possible concept forms for which the composite will translate into the model's target language.
PRE: The model and composite must be defined for this composite role.
Overrides:
visitCompositeRole in class ModelVisitor
Parameters:
role - - the composite role to get the forms for.
Throws:
CoComposeException - - if the concept forms could not be retrieved.