EDU.utwente.CoCompose.translate
Class FlattenVisitorDepthFirst

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

public class FlattenVisitorDepthFirst
extends ModelVisitor
implements java.lang.Cloneable

Flattens the model using available solution patterns. Uses a depth first strategy, so it can already return after flattening one option.

Version:
0.1.16, 31 October 2003
Author:
Dennis Wagelaar

Field Summary
protected  boolean flattenNeeded
          When false, flattening did not change model, so it was not needed.
 
Fields inherited from class EDU.utwente.CoCompose.lang.ModelVisitor
log
 
Constructor Summary
FlattenVisitorDepthFirst()
          Constructs a FlattenVisitor.
 
Method Summary
protected  void addDontFlatten(Composite composite)
          Adds a composite to the set of composites that should not be flattened.
protected  java.lang.Object clone()
          Create a shared copy of this.
protected  boolean dontFlatten(Composite composite)
          Checks whether a composite should be flattened based on the set of composites that need not be flattened.
protected  SolutionPattern getCurrentOption()
          Gets the current flattening option for this visitor to continue at.
 Model getFlatModel()
          Gets the flattened model so far.
protected  boolean getFull()
          Gets full flattening.
 FlattenVisitorDepthFirst getNextFlattenVisitor()
          Gets the next flattening option branch visitor.
protected  void setCurrentOption(SolutionPattern currentOption)
          Sets the current flattening option for this visitor to continue at.
protected  void setFlatModel(Model flatModel)
          Sets the flattened model so far.
 void setFull(boolean full)
          Sets full flattening.
 void setLogger(Logger logger)
          Sets the logger object.
protected  void setNextFlattenVisitor(FlattenVisitorDepthFirst nextFlatten)
          Sets the next flattening option branch visitor.
 void visitComposite(Composite composite)
          Flattens a Composite object.
 void visitModel(Model model)
          Flattens the model.
 
Methods inherited from class EDU.utwente.CoCompose.lang.ModelVisitor
getUpdate, run, setErrorReporter, setUpdate, startModel, visitAbstractConcept, visitCompositePartConcept, visitCompositeRole, visitConcept, visitConstrainedConcept, visitImplementation, visitImplementationGenerator, visitImplementationRolePart, visitLink, visitPublishedConcept, visitSolutionPattern, visitSolutionRole
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flattenNeeded

protected boolean flattenNeeded
When false, flattening did not change model, so it was not needed.
Constructor Detail

FlattenVisitorDepthFirst

public FlattenVisitorDepthFirst()
Constructs a FlattenVisitor.
Method Detail

getFull

protected boolean getFull()
Gets full flattening.
Returns:
If true, does full flattening, otherwise one level flattening.

setCurrentOption

protected void setCurrentOption(SolutionPattern currentOption)
Sets the current flattening option for this visitor to continue at.
Parameters:
currentOption - The current flattening option.

getCurrentOption

protected SolutionPattern getCurrentOption()
Gets the current flattening option for this visitor to continue at.
Returns:
The current flattening option.

setFlatModel

protected void setFlatModel(Model flatModel)
Sets the flattened model so far.
Parameters:
flatModel - The flattened model.

dontFlatten

protected boolean dontFlatten(Composite composite)
Checks whether a composite should be flattened based on the set of composites that need not be flattened.
Parameters:
composite - The composite
Returns:
True if and only if the composite should be flattened.

addDontFlatten

protected void addDontFlatten(Composite composite)
Adds a composite to the set of composites that should not be flattened. This option is used to prevent infinite loops in flattening.
Parameters:
composite - The composite that should not be flattened.

clone

protected java.lang.Object clone()
Create a shared copy of this.
Overrides:
clone in class java.lang.Object
Returns:
The copy.

setNextFlattenVisitor

protected void setNextFlattenVisitor(FlattenVisitorDepthFirst nextFlatten)
Sets the next flattening option branch visitor.
Parameters:
flatten - The next flatten visitor.

getNextFlattenVisitor

public FlattenVisitorDepthFirst getNextFlattenVisitor()
Gets the next flattening option branch visitor.
Returns:
The next flatten visitor.

setLogger

public void setLogger(Logger logger)
Sets the logger object.
Overrides:
setLogger in class ModelVisitor
Parameters:
logger - The object to log to

setFull

public void setFull(boolean full)
Sets full flattening.
Parameters:
full - If true, does full flattening, otherwise one level flattening.

getFlatModel

public Model getFlatModel()
Gets the flattened model so far.
Returns:
The flattened model.

visitModel

public void visitModel(Model model)
                throws CoComposeException
Flattens the model.
Overrides:
visitModel in class ModelVisitor
Parameters:
model - The model to flatten.
Throws:
CoComposeException - if one of the model's constraints are not fulfilled or if the model could not be flattened.

visitComposite

public void visitComposite(Composite composite)
                    throws CoComposeException
Flattens a Composite object.
Overrides:
visitComposite in class ModelVisitor
Parameters:
composite - The composite to flatten.
Throws:
CoComposeException - if the composite cannot be flattened for the target language of the model.