EDU.utwente.CoCompose.translate
Class GenerateImplementationVisitor

java.lang.Object
  extended byEDU.utwente.CoCompose.lang.ModelVisitor
      extended byEDU.utwente.CoCompose.translate.GenerateImplementationVisitor
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
JavaImplementationVisitor

public abstract class GenerateImplementationVisitor
extends ModelVisitor

Abstract Generate Implementation visitor for generating implementation from CoCompose Models.

Version:
0.1.15, 20 October 2003
Author:
Dennis Wagelaar

Field Summary
protected  FormConstraintsVisitor constraintCheck
          The form checking visitor needed to check constraints
static java.lang.String Indent
          Indentation string (two spaces by default).
static java.lang.String OUTPUT_DIR
          File output directory for all generated implementation files.
 
Fields inherited from class EDU.utwente.CoCompose.lang.ModelVisitor
log
 
Constructor Summary
GenerateImplementationVisitor()
          Constructs a GenerateImplementationVisitor.
 
Method Summary
protected  void dumpImplementation(Model model, java.lang.String outdir)
          Dumps the implementation on standard out.
protected  java.util.Hashtable getForms()
          Gets the concept forms in the model: Concept |-> String.
 java.lang.String getImpl(Concept concept)
          Gets the implementation for a concept.
 java.lang.String getImpl(UniqueRealm realm)
          Gets the implementation for a unique realm.
protected  java.lang.String getImplementation(Concept concept, java.lang.String form, boolean indent)
          Gets the first working implementation for the given concept and returns its contents.
protected  java.lang.String getImplementation(Implementation impl)
          Checks and returns the implementation content, if check ok.
protected  java.util.Hashtable getImpls()
          Gets the implementations for the concepts and unique realms.
abstract  java.lang.String getTargetLanguage()
          Returns the target language this GenerateImplementationVisitor supports.
 java.lang.String indent(java.lang.String impl)
          Returns an indented implementation.
protected  void removeForm(Concept concept)
          Removes a concept form mapping.
protected  void setForm(Concept concept, java.lang.String form)
          Sets a concept form for a concept.
 void setImpl(Concept concept, java.lang.String implementation)
          Sets the implementation for a Concept.
 void setImpl(UniqueRealm realm, java.lang.String implementation)
          Sets the implementation for a UniqueRealm.
 void visitComposite(Composite composite)
          Generates implementation for a Composite object.
 void visitConcept(Concept concept)
          Generates implementation for a Concept object.
 void visitImplementation(Implementation implementation)
          Generates implementation for an Implementation object.
 void visitImplementationGenerator(ImplementationGenerator implementation)
          Generates implementation for an ImplementationGenerator object.
 void visitModel(Model model)
          Visits a Model object.
protected  void writeFile(java.lang.String dir, java.lang.String filename, java.lang.String content)
          Writes the content to the designed file.
 
Methods inherited from class EDU.utwente.CoCompose.lang.ModelVisitor
getUpdate, run, setErrorReporter, setLogger, setUpdate, startModel, visitAbstractConcept, visitCompositePartConcept, visitCompositeRole, visitConstrainedConcept, 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

Indent

public static final java.lang.String Indent
Indentation string (two spaces by default).

See Also:
Constant Field Values

OUTPUT_DIR

public static final java.lang.String OUTPUT_DIR
File output directory for all generated implementation files.

See Also:
Constant Field Values

constraintCheck

protected FormConstraintsVisitor constraintCheck
The form checking visitor needed to check constraints

Constructor Detail

GenerateImplementationVisitor

public GenerateImplementationVisitor()
Constructs a GenerateImplementationVisitor.

Method Detail

getForms

protected java.util.Hashtable getForms()
Gets the concept forms in the model: Concept |-> String.

Returns:
The concept forms per concept.

setForm

protected void setForm(Concept concept,
                       java.lang.String form)
Sets a concept form for a concept.

Parameters:
concept - The concept to set the form for.
form - The concept form to set.

removeForm

protected void removeForm(Concept concept)
Removes a concept form mapping.

Parameters:
concept - The concept to remove.

getImpls

protected java.util.Hashtable getImpls()
Gets the implementations for the concepts and unique realms.

Returns:
The implementations. Structure: (Concept | UniqueRealm) |-> String.

getImplementation

protected java.lang.String getImplementation(Concept concept,
                                             java.lang.String form,
                                             boolean indent)
Gets the first working implementation for the given concept and returns its contents.

Parameters:
concept - The concept to get the implementation for.
form - The concept form that the implementation must implement.
indent - If true, returns indented implementation.
Returns:
The first working implementation or an empty string if not applicable.

getImplementation

protected java.lang.String getImplementation(Implementation impl)
                                      throws CoComposeException
Checks and returns the implementation content, if check ok.

Parameters:
impl - - the implementation to check
Returns:
the content of impl, if check ok
Throws:
CoComposeException - if check not ok

writeFile

protected void writeFile(java.lang.String dir,
                         java.lang.String filename,
                         java.lang.String content)
                  throws CoComposeException
Writes the content to the designed file.

Parameters:
dir - The file directory.
filename - The file name.
content - The file content to write.
Throws:
CoComposeException - if writing failed.

dumpImplementation

protected void dumpImplementation(Model model,
                                  java.lang.String outdir)
                           throws CoComposeException
Dumps the implementation on standard out.

Parameters:
model - The model to dump the implementation for.
outdir - The directory to save the dump file.
Throws:
CoComposeException - if writing the implementation dump failed.

getTargetLanguage

public abstract java.lang.String getTargetLanguage()
Returns the target language this GenerateImplementationVisitor supports.

Returns:
The target language.

indent

public java.lang.String indent(java.lang.String impl)
Returns an indented implementation.

Parameters:
impl - The current implementation.
Returns:
The indented implementation.

setImpl

public void setImpl(Concept concept,
                    java.lang.String implementation)
Sets the implementation for a Concept.

Parameters:
concept - The concept to set the implementation for.
implementation - The implementation to set.

setImpl

public void setImpl(UniqueRealm realm,
                    java.lang.String implementation)
Sets the implementation for a UniqueRealm.

Parameters:
realm - The unique realm to set the implementation for.
implementation - The implementation to set.

getImpl

public java.lang.String getImpl(Concept concept)
Gets the implementation for a concept.

Returns:
The implementation.

getImpl

public java.lang.String getImpl(UniqueRealm realm)
Gets the implementation for a unique realm.

Returns:
The implementation.

visitModel

public void visitModel(Model model)
                throws CoComposeException
Visits a Model object.

Overrides:
visitModel in class ModelVisitor
Parameters:
model - The model to visit.
Throws:
CoComposeException - if visiting operation failed.

visitConcept

public void visitConcept(Concept concept)
                  throws CoComposeException
Generates implementation for a Concept object.

Overrides:
visitConcept in class ModelVisitor
Parameters:
concept - The concept to visit.
Throws:
CoComposeException - if generating implementation failed.

visitComposite

public void visitComposite(Composite composite)
                    throws CoComposeException
Generates implementation for a Composite object.
PRE: The model attribute must be defined for the composite.

Overrides:
visitComposite in class ModelVisitor
Parameters:
composite - The composite to visit.
Throws:
CoComposeException - if generating implementation failed.

visitImplementation

public void visitImplementation(Implementation implementation)
                         throws CoComposeException
Generates implementation for an Implementation object.

Overrides:
visitImplementation in class ModelVisitor
Parameters:
implementation - The concept implementation to visit.
Throws:
CoComposeException - if generating implementation failed.

visitImplementationGenerator

public void visitImplementationGenerator(ImplementationGenerator implementation)
                                  throws CoComposeException
Generates implementation for an ImplementationGenerator object.

Overrides:
visitImplementationGenerator in class ModelVisitor
Parameters:
implementation - The implementation generator to visit.
Throws:
CoComposeException - if generating implementation failed.