Poseidon for UMLTM
  UMLdoc
 PREV  CLASSIFIER    NEXT  CLASSIFIER     FRAMES    NO FRAMES      
SUMMARY:   INNER | ATTR | ASSOC | CONSTR | METHOD     DETAIL:   INNER | ATTR | ASSOC | CONSTR | METHOD     DIAGRAMS:   COLLAB | SEQ | STATE | ACTIV

com.gentleware.poseidon.generator

Class CoreGenerator

com.gentleware.poseidon.generator.CoreGenerator
All known Subclassifier:
UMLGenerator

All known implemented Interfaces:
Generator


public abstract class CoreGenerator


The CoreGenerator gives a default implementation for some methods without making assumptions about the code generation domain.

Authors:
Thorsten Sturm
See also:
ElementPreparator


 Attribute Summary
private static String  ENHANCED_EDITOR_PLUGIN_NAME
 
private static String  FILE_SUFFIX_SEPARATOR
 
private static String  TEMPFILE_PREFIX
 
private static String  TEMPFILE_SUFFIX
 
private Map  _externalLibraries
 
private boolean  _isInitialized
 
private List  _libraryPathList
 
private String  _logIdPrefix
 
private boolean  _usesPredicates
 
arrow_up
 

 Association Summary
private ExternalEntryStrategy  _externalLibraryStrategy
 
private ElementPreparator  _preparator
 
private CodeTemplateManager  _templateManager
 
private TemplateStrategy  _templateStrategy
 
arrow_up
 

 Constructor Summary
public   CoreGenerator()
 
arrow_up
 

 Method Summary
public void   addExternalLibraries(String origin, List libraries)
Adds a list of paths to externally known macro libraries and maps them to origin of knowledge. 
public void   addExternalLibraries(String origin, List libraries, boolean treatAsUnencrypted)
Adds a list of paths to externally known macro libraries and maps them to origin of knowledge. 
public boolean   addMacroLibrary(String path)
Adds the path to a new macro library to the list of needed libraries. 
public boolean   addMacroLibrary(String path, boolean treatAsUnencrypted)
Adds the path to a new macro library to the list of needed libraries. 
private static String   createFilename(String targetLocation, String fileName, String fileSuffix)
 
protected List   generateFiles(Object element, String path, Object predicate)
 
public List   generateFiles(RefObject primaryClassifier, List secondaryClassifiers, String path)
 
protected List   generateFilesToPersistTarget(Object element, String targetLocation, Object predicate)
 
private static void   generateFromTemplate(CodeTemplate codeTemplate, StringWriter writer)
 
protected List   generateMultipleOnTheFly(Object element, Object predicate)
 
public String   generateTarget(Object element, Object predicate, int templateIndex)
Generates the code for the given element. 
public List   generateTargets(Object element, String targetLocation, Object predicate)
Generates the code for the given element at the desired target location. 
protected List   generateToMultipleDisplays(Object element, Object predicate)
Generates code to string for a given uml element and a predicate for choosing the templates. 
protected String   getCalculatedPathToFile(PreparedElement preparedElement, String path, boolean pathOnly)
 
private CodeTemplate   getCodeTemplate(Object element, Object predicate, int templateIndex)
 
public Map   getFilenamesForElement(Object element, String targetLocation)
Returns the list of absolute file names and paths for all source file suffuxes registered for the given element. 
private Map   getFilenamesForPreparedElement(PreparedElement prepElement, String targetLocation)
 
public List   getMacroLibraries()
Returns the velocity macro libraries that need to be added to the macro pool in order to make the code generation work. 
protected String   getPathToFile(PreparedElement preparedElement, String path)
 
protected Map   getPathsToFile(PreparedElement preparedElement, String path)
 
public String   getPlainFilenameForElement(Object element, String targetLocation)
Returns the plain filename for the given element. 
public ElementPreparator   getPreparator()
Returns the corresponding ElementPreparator instance. 
private String   getPreparedElementFilename(PreparedElement prepElement, String targetLocation)
 
public CodeTemplateManager   getTemplateManager()
Returns the CodeTemplateManager currently registered for this generator. 
protected TemplateStrategy   getTemplateStrategy()
 
public void   initInternal()
Initializes the generator instance. 
private StringWriter   initializeTemplateAndWriter(Object element, CodeTemplate codeTemplate)
 
public boolean   isCompiling()
True if some locking property is true; depends on the implementations. 
public boolean   isInitialized()
 
public void   removeExternalLibraries(String origin)
Removes the list of paths to macro libraries known from the given origin. 
public boolean   removeMacroLibrary(String path)
Removes the path to a macro library from the list of needed libraries. 
public void   setExternalLibraryStrategy(ExternalEntryStrategy strategy)
Set the strategy used to decide how to handle external libraries. 
protected void   setInitialized(boolean initialized)
 
protected void   setPreparator(ElementPreparator preparator)
Sets the element preparator instance this generator will use. 
public void   setTemplateManager(CodeTemplateManager templateManager)
Sets the CodeTemplateManager to be used by this generator to a new instance. 
public void   setTemplateStrategy(TemplateStrategy strategy)
Set the strategy used to handle templates for special element classes. 
protected void   setUsesPredicates(boolean shouldUsePredicates)
 
protected boolean   useExternalEntries(String origin)
 
public boolean   usesPredicates()
Tests, if the generator controller should use the predicate-based generation framework. 
arrow_up
 

Tagged Values
static false
 

 Attribute Detail

ENHANCED_EDITOR_PLUGIN_NAME

private static String ENHANCED_EDITOR_PLUGIN_NAME

arrow_up


FILE_SUFFIX_SEPARATOR

private static String FILE_SUFFIX_SEPARATOR

arrow_up


TEMPFILE_PREFIX

private static String TEMPFILE_PREFIX

arrow_up


TEMPFILE_SUFFIX

private static String TEMPFILE_SUFFIX

arrow_up


_externalLibraries

private Map _externalLibraries

arrow_up


_isInitialized

private boolean _isInitialized

arrow_up


_libraryPathList

private List _libraryPathList

arrow_up


_logIdPrefix

private String _logIdPrefix

arrow_up


_usesPredicates

private boolean _usesPredicates

arrow_up
 Association Detail

_externalLibraryStrategy

private ExternalEntryStrategy _externalLibraryStrategy

arrow_up


_preparator

private ElementPreparator _preparator

arrow_up


_templateManager

private CodeTemplateManager _templateManager

arrow_up


_templateStrategy

private TemplateStrategy _templateStrategy

arrow_up
 Constructor Detail

CoreGenerator

public CoreGenerator CoreGenerator()

Returns:
arrow_up
 Method Detail

addExternalLibraries

public void addExternalLibraries(String origin, List libraries)


Adds a list of paths to externally known macro libraries and maps them to origin of knowledge. All libraries will be treated as unencrypted.  
Parameters:
origin - Place where the knowledge about the libraries comes from (e.g. a plugin).
libraries - List of paths to the externally known macro libraries.
arrow_up


addExternalLibraries

public void addExternalLibraries(String origin, List libraries, boolean treatAsUnencrypted)


Adds a list of paths to externally known macro libraries and maps them to origin of knowledge.  
Parameters:
origin - Place where the knowledge about the libraries comes from (e.g. a plugin).
libraries - List of paths to the externally known macro libraries.
treatAsUnencrypted - True, if the libraries should be treated as unencrypted.
arrow_up


addMacroLibrary

public boolean addMacroLibrary(String path)


Adds the path to a new macro library to the list of needed libraries. The template will be treated as encrypted.  
Parameters:
path - Path to the new macro library.
Returns:
True, if adding was successful, otherwise false.
arrow_up


addMacroLibrary

public boolean addMacroLibrary(String path, boolean treatAsUnencrypted)


Adds the path to a new macro library to the list of needed libraries.  
Parameters:
path - Path to the new macro library.
treatAsUnencrypted - True, if the template should be treated as unencrypted.
Returns:
True, if adding was successful, otherwise false.
arrow_up


createFilename

private static String createFilename(String targetLocation, String fileName, String fileSuffix)

Parameters:
targetLocation -
fileName -
fileSuffix -
Returns:
arrow_up


generateFiles

protected List generateFiles(Object element, String path, Object predicate)

Parameters:
element -
path -
predicate -
Returns:
arrow_up


generateFiles

public List generateFiles(RefObject primaryClassifier, List secondaryClassifiers, String path)

Parameters:
primaryClassifier -
secondaryClassifiers -
path -
Returns:
arrow_up


generateFilesToPersistTarget

protected List generateFilesToPersistTarget(Object element, String targetLocation, Object predicate)

Parameters:
element -
targetLocation -
predicate -
Returns:
arrow_up


generateFromTemplate

private static void generateFromTemplate(CodeTemplate codeTemplate, StringWriter writer)

Parameters:
codeTemplate -
writer -
arrow_up


generateMultipleOnTheFly

protected List generateMultipleOnTheFly(Object element, Object predicate)

Parameters:
element -
predicate -
Returns:
arrow_up


generateTarget

public String generateTarget(Object element, Object predicate, int templateIndex)


Generates the code for the given element. The template to be used for the generation process is identified by the given predicate and its index in the identified template set.  
Parameters:
element - The element code should generated for.
predicate - The predicate used to find out the right template set. In the simplest case, a lowercase string designating the language.
templateIndex - The index of the template in the template set identified through the predicate.
Returns:
The generated code or an error message. In the simplest case, a lowercase string designating the language.
Since:
1.6
arrow_up


generateTargets

public List generateTargets(Object element, String targetLocation, Object predicate)


Generates the code for the given element at the desired target location. The target location usually describes the path to a file, but can also be something different (e.g. a table in a relational database). If the targetLocation is set to null, the generation assumes a display as target. Multiple files can be created for reflecting different parts of the code.  
Parameters:
element - The element code should generated for.
targetLocation - A String describing the location of the target or null.
predicate -
Returns:
The paths to the target location or the generated code when no target is specified.
arrow_up


generateToMultipleDisplays

protected List generateToMultipleDisplays(Object element, Object predicate)


Generates code to string for a given uml element and a predicate for choosing the templates.  
Parameters:
element - Uml element to generate code for.
predicate - Predicate for choosing the templates
Returns:
A list containing generated code in String format for any chosen template.
arrow_up


getCalculatedPathToFile

protected String getCalculatedPathToFile(PreparedElement preparedElement, String path, boolean pathOnly)

Parameters:
preparedElement -
path -
pathOnly -
Returns:
arrow_up


getCodeTemplate

private CodeTemplate getCodeTemplate(Object element, Object predicate, int templateIndex)

Parameters:
element -
predicate -
templateIndex -
Returns:
arrow_up


getFilenamesForElement

public Map getFilenamesForElement(Object element, String targetLocation)


Returns the list of absolute file names and paths for all source file suffuxes registered for the given element. Beside the model structure, the designated target directory is part of the generated path.  
Parameters:
element - The element the file should be generated for.
targetLocation - The directory where the generated files should be created in.
Returns:
A map containing the absolute path and file name per suffix.
arrow_up


getFilenamesForPreparedElement

private Map getFilenamesForPreparedElement(PreparedElement prepElement, String targetLocation)

Parameters:
prepElement -
targetLocation -
Returns:
arrow_up


getMacroLibraries

public List getMacroLibraries()


Returns the velocity macro libraries that need to be added to the macro pool in order to make the code generation work. The returned list consists of the paths to the default libraries as well as to the currently valid external libraries.  
Returns:
List of paths to the needed macro libraries. Each entry is a String.
arrow_up


getPathToFile

protected String getPathToFile(PreparedElement preparedElement, String path)

Parameters:
preparedElement -
path -
Returns:
arrow_up


getPathsToFile

protected Map getPathsToFile(PreparedElement preparedElement, String path)

Parameters:
preparedElement -
path -
Returns:
arrow_up


getPlainFilenameForElement

public String getPlainFilenameForElement(Object element, String targetLocation)


Returns the plain filename for the given element. No extensions are used to calculate the name. This method should be declared abstract in the next framework iteration. It is currently not for backward compatibility reasons..  
Parameters:
element - The element to calculate the name for.
targetLocation - The directory where the generated files should be created in.
Returns:
A string representing the calculated plain name.
arrow_up


getPreparator

public ElementPreparator getPreparator()


Returns the corresponding ElementPreparator instance.  
Returns:
The corresponding instance of ElementPreparator.
arrow_up


getPreparedElementFilename

private String getPreparedElementFilename(PreparedElement prepElement, String targetLocation)

Parameters:
prepElement -
targetLocation -
Returns:
arrow_up


getTemplateManager

public CodeTemplateManager getTemplateManager()


Returns the CodeTemplateManager currently registered for this generator.  
Returns:
The currently registered CodeTemplateManager.
Since:
1.6
arrow_up


getTemplateStrategy

protected TemplateStrategy getTemplateStrategy()

Returns:
arrow_up


initInternal

public void initInternal()


Initializes the generator instance.  
arrow_up


initializeTemplateAndWriter

private StringWriter initializeTemplateAndWriter(Object element, CodeTemplate codeTemplate)

Parameters:
element -
codeTemplate -
Returns:
arrow_up


isCompiling

public boolean isCompiling()


True if some locking property is true; depends on the implementations. This method is used by Roundtrip to check whether this is a good time to import or check for imports. GeneratePre starts this critical section and compilePost ends it.  
Returns:
arrow_up


isInitialized

public boolean isInitialized()

Returns:
arrow_up


removeExternalLibraries

public void removeExternalLibraries(String origin)


Removes the list of paths to macro libraries known from the given origin.  
Parameters:
origin - Place where the knowledge about the libraries comes from (e.g. a plugin).
arrow_up


removeMacroLibrary

public boolean removeMacroLibrary(String path)


Removes the path to a macro library from the list of needed libraries.  
Parameters:
path - Path to the macro library.
Returns:
True, if removal was successful, otherwise false.
arrow_up


setExternalLibraryStrategy

public void setExternalLibraryStrategy(ExternalEntryStrategy strategy)


Set the strategy used to decide how to handle external libraries.  
Parameters:
strategy - The strategy containing the decision implementation.
arrow_up


setInitialized

protected void setInitialized(boolean initialized)

Parameters:
initialized -
arrow_up


setPreparator

protected void setPreparator(ElementPreparator preparator)


Sets the element preparator instance this generator will use.  
Parameters:
preparator - The element preparator instance this generator will use.
arrow_up


setTemplateManager

public void setTemplateManager(CodeTemplateManager templateManager)


Sets the CodeTemplateManager to be used by this generator to a new instance.  
Parameters:
templateManager - The new instance of CodeTemplateManager.
Since:
1.6n
arrow_up


setTemplateStrategy

public void setTemplateStrategy(TemplateStrategy strategy)


Set the strategy used to handle templates for special element classes.  
Parameters:
strategy - The strategy containing the handling implementation.
arrow_up


setUsesPredicates

protected void setUsesPredicates(boolean shouldUsePredicates)

Parameters:
shouldUsePredicates -
arrow_up


useExternalEntries

protected boolean useExternalEntries(String origin)

Parameters:
origin -
Returns:
arrow_up


usesPredicates

public boolean usesPredicates()


Tests, if the generator controller should use the predicate-based generation framework.  
Returns:
True, if the predicate-based generation framework should be used, otherwise false.
Since:
1.6
arrow_up
Created  2004 - 10 - 21

    Poseidon for UMLTM
  UMLdoc
 PREV  CLASSIFIER    NEXT  CLASSIFIER     FRAMES    NO FRAMES      
SUMMARY:   INNER | ATTR | ASSOC | CONSTR | METHOD     DETAIL:   INNER | ATTR | ASSOC | CONSTR | METHOD     DIAGRAMS:   COLLAB | SEQ | STATE | ACTIV

Generated with Poseidon for UMLTM.
Poseidon is a registered trademark of Gentleware AG in Germany, USA and other countries. Copyright 2003-2004 Gentleware AG, Schanzenstr. 70, 20357 Hamburg, Germany. All Rights Reserved.

UML is a trademark or registered trademark of Object Management Group, Inc. in the U.S. and other countries.