translate
Class JavaImplementationVisitor

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

public class JavaImplementationVisitor
extends GenerateImplementationVisitor

Generates Java implementation for a CoCompose model.

Version:
0.1.20, 17 March 2004
Author:
Dennis Wagelaar

Field Summary
 
Fields inherited from class EDU.utwente.CoCompose.translate.GenerateImplementationVisitor
constraintCheck, Indent, OUTPUT_DIR
 
Fields inherited from class EDU.utwente.CoCompose.lang.ModelVisitor
log
 
Constructor Summary
JavaImplementationVisitor()
          Constructs a JavaImplementationVisitor.
 
Method Summary
protected  void conceptAsClass(Concept concept, java.lang.String form)
          Implements the concept as a Class.
protected  void conceptAsConstructorMethod(Concept concept, java.lang.String form)
          Implements the concept as a ConstructorMethod.
protected  void conceptAsInterface(Concept concept)
          Implements the concept as an Interface.
protected  void conceptAsMethod(Concept concept, java.lang.String form)
          Implements the concept as a Method.
protected  void conceptAsOther(Concept concept, java.lang.String form)
          Implements the concept as another form.
protected  java.lang.String getImplementation(Implementation impl)
          Checks and returns the implementation content, if check ok.
protected  java.lang.String getImplPart(java.lang.String attr, java.lang.String impl)
          Retrieves the right part from the implementation.
protected  java.lang.String getPointerAttribute(java.lang.String attr, java.lang.String impl)
          Gets the pointer attribute part of the implementation for the given entity.
 java.lang.String getTargetLanguage()
          Returns the target language this GenerateImplementationVisitor supports.
protected  void moveImports()
          Moves the import declarations in the implementations to the right place.
protected  void removeExtraNewlines()
          Removes superfluous newlines in the implementations.
protected  void substVars()
          Substitutes predefined variables.
 void visitConcept(Concept concept)
          Generates implementation for a Concept object.
 void visitModel(Model model)
          Visits a Model object.
protected  void weavePointers(Model model)
          Weaves the designated implementations into the pointers.
protected  void weavePointers(Model model, java.lang.Object entity)
          Weaves the designated implementations into the pointers for the given concept.
protected  void writeImplementation(Model model, java.lang.String outdir)
          Writes the implementation of the model.
 
Methods inherited from class EDU.utwente.CoCompose.translate.GenerateImplementationVisitor
dumpImplementation, getForms, getImpl, getImpl, getImplementation, getImpls, indent, removeForm, setForm, setImpl, setImpl, visitComposite, visitImplementation, visitImplementationGenerator, writeFile
 
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
 

Constructor Detail

JavaImplementationVisitor

public JavaImplementationVisitor()
Constructs a JavaImplementationVisitor.

Method Detail

getImplementation

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

Overrides:
getImplementation in class GenerateImplementationVisitor
Parameters:
impl - - the implementation to check
Returns:
the content of impl, if check ok
Throws:
CoComposeException - if check not ok

conceptAsClass

protected void conceptAsClass(Concept concept,
                              java.lang.String form)
Implements the concept as a Class.

Parameters:
concept - The concept to implement.
form - The exact concept form.

conceptAsInterface

protected void conceptAsInterface(Concept concept)
Implements the concept as an Interface.

Parameters:
concept - The concept to implement.

conceptAsMethod

protected void conceptAsMethod(Concept concept,
                               java.lang.String form)
Implements the concept as a Method.

Parameters:
concept - The concept to implement.
form - The exact concept form.

conceptAsConstructorMethod

protected void conceptAsConstructorMethod(Concept concept,
                                          java.lang.String form)
Implements the concept as a ConstructorMethod.

Parameters:
concept - The concept to implement.
form - The form to implement the concept as.

conceptAsOther

protected void conceptAsOther(Concept concept,
                              java.lang.String form)
Implements the concept as another form.

Parameters:
concept - The concept to implement.
form - The form to implement the concept as.

weavePointers

protected void weavePointers(Model model)
                      throws CoComposeException
Weaves the designated implementations into the pointers.

Parameters:
model - The source model to read the pointers from.
Throws:
CoComposeException - if weaving failed.

weavePointers

protected void weavePointers(Model model,
                             java.lang.Object entity)
                      throws CoComposeException
Weaves the designated implementations into the pointers for the given concept.

Parameters:
model - The source model to read the pointers from.
entity - The entity of which to adapt the implementation.
Throws:
CoComposeException - if weaving failed.

substVars

protected void substVars()
                  throws CoComposeException
Substitutes predefined variables. Known variables:

Throws:
CoComposeException - if substituting failed.

getImplPart

protected java.lang.String getImplPart(java.lang.String attr,
                                       java.lang.String impl)
                                throws CoComposeException
Retrieves the right part from the implementation.

Parameters:
attr - The pointer attributes, if any.
impl - The current implementation.
Returns:
The correct part of the implementation.
Throws:
CoComposeException - if the part could not be found.

getPointerAttribute

protected java.lang.String getPointerAttribute(java.lang.String attr,
                                               java.lang.String impl)
                                        throws CoComposeException
Gets the pointer attribute part of the implementation for the given entity.

Parameters:
attr - The pointer attribute identifier.
impl - The implementation to get the attribute part for.
Throws:
CoComposeException - if the part could not be found.

moveImports

protected void moveImports()
Moves the import declarations in the implementations to the right place.


removeExtraNewlines

protected void removeExtraNewlines()
Removes superfluous newlines in the implementations.


writeImplementation

protected void writeImplementation(Model model,
                                   java.lang.String outdir)
                            throws CoComposeException
Writes the implementation of the model.

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

getTargetLanguage

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

Specified by:
getTargetLanguage in class GenerateImplementationVisitor
Returns:
The target language.

visitModel

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

Overrides:
visitModel in class GenerateImplementationVisitor
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 GenerateImplementationVisitor
Parameters:
concept - The concept to visit.
Throws:
CoComposeException - if generating implementation failed.