Class GlobalExtensionManagement
java.lang.Object
de.monticore.generating.templateengine.GlobalExtensionManagement
Class for managing hook points, features and (global) variables in templates.
Order of template replacement:
- specific before hook points
- general before hook points
- specific replacement or general replacement
- specific after hook points
- general after hook points
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected freemarker.template.SimpleHashMap of all hook points for explicitely define hook points (which are internally managed to be disjoint from the template hook points) This also means explicitely define hook points cannot be decorated with "before" or "after" and they also do not contain a list, but only a single realization. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAfterTemplate(String template, ASTNode ast, HookPoint afterHp) Everytime 'template' is included directly for node 'ast' (e.g.voidaddAfterTemplate(String template, HookPoint afterHp) Everytime 'template' is included directly (e.g.voidaddBeforeTemplate(String template, ASTNode ast, HookPoint beforeHp) Everytime 'template' is included directly for node 'ast' (e.g.voidaddBeforeTemplate(String template, HookPoint beforeHp) Everytime 'template' is included directly (e.g.voidaddToGlobalVar(String name, Object value) Adds a new value to the given name.voidbindHookPoint(String hookName, HookPoint hp) voidbindStringHookPoint(String hookName, String content) voidbindTemplateHookPoint(String hookName, String tpl) voidbindTemplateStringHookPoint(String hookName, String content) voidchangeGlobalVar(String name, Object value) Changes the value of an existing global variable.protected booleancontainsTemplateForwarding(String templateName) voiddefineGlobalVar(String name, Object value) Defines a new value which can be accessed with the given name in the templates.defineHookPoint(TemplateController controller, String hookName) defineHookPoint(TemplateController controller, String hookName, ASTNode ast) defineHookPoint(TemplateController controller, String hookName, ASTNode ast, Object... args) defineHookPoint(TemplateController controller, String hookName, Object... args) defineHookPointWithDefault(TemplateController controller, String hookName, ASTNode ast, String defStr) defineHookPointWithDefault(TemplateController controller, String hookName, ASTNode ast, String defStr, Object... args) defineHookPointWithDefault(TemplateController controller, String hookName, String defStr) defineHookPointWithDefault(TemplateController controller, String hookName, String defStr, Object... args) booleanexistsHookPoint(String hookName) getAfterTemplates(String templateName, ASTNode ast) getBeforeTemplates(String templateName, ASTNode ast) getGlobalVar(String name) Returns the value of the given variable.getGlobalVar(String name, Object defaultObject) Returns the value of the given variable.getSpecificReplacement(String templateName, ASTNode ast, Map<String, Map<ASTNode, HookPoint>> specific) getTemplateForwardings(String templateName, ASTNode ast) Returns a set of templates that have been defined to replace the templatetemplateName.getTemplateForwardingsX(String templateName, ASTNode ast) Returns a set of templates that have been defined to replace the 'templateName' template.booleanhasGlobalVar(String name) Checks whether a value with the given name is defined and is not nullvoidreplaceTemplate(String oldTemplate, ASTNode node, HookPoint newHp) voidreplaceTemplate(String oldTemplate, HookPoint hp) Future inclusion of 'oldTemplate' will be replaced by 'newTemplate'.voidreplaceTemplate(String oldTemplate, List<? extends HookPoint> newHps) Future inclusion of 'oldTemplate' will be replaced by list of 'newTemplates'.voidrequiredGlobalVar(String name) check whether the variable name (parameter) is defined: if not issue an error and continuevoidrequiredGlobalVars(String... names) check whether the list of variable names (parameter) is defined: if not issue an error and continuevoidsetAfterTemplate(String template, ASTNode ast, HookPoint afterHp) Everytime 'template' is included directly for node 'ast' (e.g.voidsetAfterTemplate(String template, ASTNode ast, List<HookPoint> afterHps) Everytime 'template' is included directly for node 'ast' (e.g.voidsetAfterTemplate(String template, HookPoint afterHp) Everytime 'template' is included directly (e.g.voidsetAfterTemplate(String template, List<? extends HookPoint> afterHps) Everytime 'template' is included directly (e.g.voidsetBeforeTemplate(String template, ASTNode ast, HookPoint beforeHp) Everytime 'template' is included directly for node 'ast' (e.g.voidsetBeforeTemplate(String template, ASTNode ast, List<HookPoint> beforeHps) Everytime 'template' is included directly for node 'ast' (e.g.voidsetBeforeTemplate(String template, HookPoint beforeHp) Everytime 'template' is included directly (e.g.voidsetBeforeTemplate(String template, List<? extends HookPoint> beforeHps) Everytime 'template' is included directly (e.g.voidsetGlobalData(freemarker.template.SimpleHash data) Set a list of global data.voidsetGlobalValue(String name, Object value) Sets a new value which can be accessed with the given name in the templates.Returns a new string hook point.templateHP(String template) Returns a new template hook point.templateStringHP(String statement) Returns a new template string hook point.protected voidwarnIfHookPointExists(String hookName)
-
Field Details
-
globalData
protected freemarker.template.SimpleHash globalData -
before
-
replace
-
after
-
specificReplacement
-
specificBefore
-
specificAfter
-
hookPoints
Map of all hook points for explicitely define hook points (which are internally managed to be disjoint from the template hook points) This also means explicitely define hook points cannot be decorated with "before" or "after" and they also do not contain a list, but only a single realization. This could be harmonized with the replace hook points (by simple integration with replacements, before and after structure)
-
-
Constructor Details
-
GlobalExtensionManagement
public GlobalExtensionManagement()
-
-
Method Details
-
setGlobalData
public void setGlobalData(freemarker.template.SimpleHash data) Set a list of global data. The parameter should not be null.- Parameters:
data- list of global data
-
hasGlobalVar
Checks whether a value with the given name is defined and is not null- Parameters:
name- of the value to check- Returns:
- true if a variable exists and its value is not null
-
setGlobalValue
Sets a new value which can be accessed with the given name in the templates. If the name is already in use an error is reported the previous value is overridden.- Parameters:
name- of the value to setvalue- the actual content
-
defineGlobalVar
Defines a new value which can be accessed with the given name in the templates. If the name is already in use an error is reported.- Parameters:
name- of the value to setvalue- the actual content
-
changeGlobalVar
Changes the value of an existing global variable. If the name is not in use an error is reported.- Parameters:
name- of the value to setvalue- the actual content
-
addToGlobalVar
Adds a new value to the given name. It converts a single value into a list if necessary.- Parameters:
name- of the value to setvalue- the actual content
-
getGlobalVar
Returns the value of the given variable.- Parameters:
name- of the variable- Returns:
- the value
-
getGlobalVar
Returns the value of the given variable.- Parameters:
name- of the variabledefaultObject- replaces if the variable is not present- Returns:
- the value or the default
-
requiredGlobalVar
check whether the variable name (parameter) is defined: if not issue an error and continue- Parameters:
name- variable name
-
requiredGlobalVars
check whether the list of variable names (parameter) is defined: if not issue an error and continue- Parameters:
names- list of variable names
-
bindStringHookPoint
- Parameters:
hookName- name of the hook pointcontent- String to be used as hook point
-
bindTemplateStringHookPoint
- Parameters:
hookName- name of the hook pointcontent- Template-content to be used as hook point
-
bindTemplateHookPoint
- Parameters:
hookName- name of the hook pointtpl- Template to be used as hook point
-
bindHookPoint
- Parameters:
hookName- name of the hook pointhp-
-
defineHookPoint
- Parameters:
hookName- name of the hook point- Returns:
- the (processed) value of the hook point
-
defineHookPointWithDefault
public String defineHookPointWithDefault(TemplateController controller, String hookName, ASTNode ast, String defStr) - Parameters:
hookName- name of the hook point- Returns:
- the (processed) value of the hook point
-
defineHookPoint
public String defineHookPoint(TemplateController controller, String hookName, ASTNode ast, Object... args) - Parameters:
hookName- name of the hook point- Returns:
- the (processed) value of the hook point
-
defineHookPointWithDefault
public String defineHookPointWithDefault(TemplateController controller, String hookName, ASTNode ast, String defStr, Object... args) - Parameters:
hookName- name of the hook point- Returns:
- the (processed) value of the hook point
-
defineHookPoint
- Parameters:
hookName- name of the hook point- Returns:
- the (processed) value of the hook point
-
defineHookPointWithDefault
public String defineHookPointWithDefault(TemplateController controller, String hookName, String defStr, Object... args) - Parameters:
hookName- name of the hook point- Returns:
- the (processed) value of the hook point
-
defineHookPoint
- Parameters:
hookName- name of the hook point- Returns:
- the (processed) value of the hook point
-
defineHookPointWithDefault
public String defineHookPointWithDefault(TemplateController controller, String hookName, String defStr) - Parameters:
hookName- name of the hook point- Returns:
- the (processed) value of the hook point
-
existsHookPoint
- Parameters:
hookName- name of the hook point- Returns:
- the (processed) value of the hook point
-
getTemplateForwardings
Returns a set of templates that have been defined to replace the templatetemplateName. If no template forwardings have been defined, thentemplateNameis returned.- Parameters:
templateName- The name of the template- Returns:
- A list of templates that have been defined to replace the 'templateNames' templates
-
getSpecificReplacement
-
getTemplateForwardingsX
Returns a set of templates that have been defined to replace the 'templateName' template. If no template forwardings have been defined, then the 'templateName' template is returned.- Parameters:
templateName- The name of the template- Returns:
- A list of templats that have been defined to replace the 'templateName' template
-
containsTemplateForwarding
-
replaceTemplate
Future inclusion of 'oldTemplate' will be replaced by 'newTemplate'. NOTE: This replacement has only an effect if 'oldTemplate' is included directly.- Parameters:
oldTemplate- qualified name of template to be replacedhp- the new hookpoint
-
replaceTemplate
Future inclusion of 'oldTemplate' will be replaced by list of 'newTemplates'. NOTE: This replacement has only an effect if 'oldTemplate' is included directly.- Parameters:
oldTemplate- qualified name of template to be replacednewHps- List of new hookpoints
-
replaceTemplate
-
setBeforeTemplate
Everytime 'template' is included directly (e.g. byTemplateController.include(String, ASTNode)), 'beforeTemplate' will be included before it.- Parameters:
template- qualified name of the templatebeforeHp- hookpoint to be included before
-
setBeforeTemplate
Everytime 'template' is included directly for node 'ast' (e.g. byTemplateController.include(String, ASTNode)), 'beforeTemplate' will be included before it.- Parameters:
template- qualified name of the templateast-beforeHp- hookpoint to be included before
-
setBeforeTemplate
Everytime 'template' is included directly (e.g. byTemplateController.include(String, ASTNode)), the templates in 'beforeTemplate' will be included before it.- Parameters:
template- qualified name of the templatebeforeHps- List of hookpoints to be included before
-
setBeforeTemplate
Everytime 'template' is included directly for node 'ast' (e.g. byTemplateController.include(String, ASTNode)), 'beforeTemplate' will be included before it.- Parameters:
template- qualified name of the templateast-beforeHps- list of hookpoints to be included before
-
setAfterTemplate
Everytime 'template' is included directly (e.g. byTemplateController.include(String, ASTNode)), the 'HookPoint' 'afterHp' will be included after it. Care: This overrides any effect that previous calls of 'addAfterTemplate' and 'setAfterTemplate' on the same template have.- Parameters:
template- qualified name of the templateafterHp- hookpoint to be included after
-
setAfterTemplate
Everytime 'template' is included directly (e.g. byTemplateController.include(String, ASTNode)), the 'HookPoints' in 'afterHps' will be included after it. Care: This overrides any effect that previous calls of 'addAfterTemplate' and 'setAfterTemplate' on the same template have.- Parameters:
template- qualified name of the templateafterHps- list of hookpoints to be included after
-
setAfterTemplate
Everytime 'template' is included directly for node 'ast' (e.g. byTemplateController.include(String, ASTNode)), the 'HookPoint' 'afterHp' will be included after it. Care: This overrides any effect that previous calls of 'addAfterTemplate' and 'setAfterTemplate' on the same template have.- Parameters:
template- qualified name of the templateast-afterHp- hookpoint to be included after
-
setAfterTemplate
Everytime 'template' is included directly for node 'ast' (e.g. byTemplateController.include(String, ASTNode)), the 'HookPoint' 'afterHp' will be included after it. Care: This overrides any effect that previous calls of 'addAfterTemplate' and 'setAfterTemplate' on the same template have.- Parameters:
template- qualified name of the templateast-afterHps- list of hookpoints to be included after
-
addAfterTemplate
Everytime 'template' is included directly (e.g. byTemplateController.include(String, ASTNode)), the template in 'afterHp' will be included after it. Multiple additions are possible. 'setAfterTemplate' overrides all additions.- Parameters:
template- qualified name of the templateafterHp- hookpoint to be included after
-
addAfterTemplate
Everytime 'template' is included directly for node 'ast' (e.g. byTemplateController.include(String, ASTNode)), the template in 'afterHp' will be included after it. Multiple additions are possible. 'setAfterTemplate' overrides all additions.- Parameters:
template- qualified name of the templateast-afterHp- hookpoint to be included after
-
addBeforeTemplate
Everytime 'template' is included directly (e.g. byTemplateController.include(String, ASTNode)), the template in 'beforHp' will be included before it. The points are added in the order in which they are called up, i.e. hookpoint 1 comes first, then hookpoint 2 and so on. Multiple additions are possible. 'setBeforeTemplate' overrides all additions.- Parameters:
template- qualified name of the templatebeforeHp- hookpoint to be included before
-
addBeforeTemplate
Everytime 'template' is included directly for node 'ast' (e.g. byTemplateController.include(String, ASTNode)), the template in 'beforeHp' will be included before it. The points are added in the order in which they are called up, i.e. hookpoint 1 comes first, then hookpoint 2 and so on. Multiple additions are possible. 'setBeforeTemplate' overrides all additions.- Parameters:
template- qualified name of the templateast-beforeHp- hookpoint to be included before
-
warnIfHookPointExists
-
templateHP
Returns a new template hook point. It executes a template and injects the result at the hook point.- Parameters:
template- qualified name of the template- Returns:
- the TemplateHookPoint
- See Also:
-
stringHP
Returns a new string hook point. It injects the uninterpreted string value at the hook point.- Parameters:
value- the uninterpreted string value- Returns:
- the StringHookPoint
- See Also:
-
templateStringHP
Returns a new template string hook point. It executes the statement as template content and injects the result at the hook point.- Parameters:
statement- the inlined template text- Returns:
- the TemplateStringHookPoint
- Throws:
IOException- See Also:
-
getBeforeTemplates
-
getAfterTemplates
-