public abstract class JiowaTemplateBeanGenerator
extends java.lang.Object
JiowaTemplateConfig
class, which is able to read multiple property
files and using "property overloading and inheritance".
Copyright (C) 2012-2015 JIOWA Business Solutions GmbH, Bettinastr. 30 , 60325 Frankfurt am Main, Germany
Homepage: www.jiowa.de
All rights reserved.
Download: www.jiowa.de/download.html
License: www.jiowa.de/license.html
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
BEAN_TEMPLATE_COMPILER_RESULT_CLASSNAME
Java class name for compile time result errrors and warnings
|
protected static java.lang.String |
BEAN_TEMPLATE_COMPILER_RESULT_FILENAME
Java class file name for compile time errors
|
protected static java.lang.String |
BEAN_TEMPLATE_FILENAME
Root bean generator template
|
protected java.io.File |
beanOutputDirectory
Output directory for template beans
|
protected java.io.File |
beanOutputDirectoryWithoutPackageName |
protected Template |
beanTemplate
The parsed bean template
|
protected TemplateMap |
beanTemplateMap
TemplateMap for bean generator templates
|
protected static java.lang.String |
BGT
Suffix for bean generator templates
|
protected static java.lang.String |
CHECK_TEMPLATE_SYNTAX_ONLY_CMD
Flag if only a syntax check on the templates has to be performed
|
protected boolean |
checkTemplateSyntaxOnly
If set to true this flag causes to check only syntax and deliver appropriate errors/warnings in the console without generating any template beans.
|
protected static java.lang.String |
COMPILER_RESULT_PACKAGE |
protected Template |
compileTimeResultTemplate
The parsed compile time result template which is used to force a compile time error if syntax errors are present in the templates
|
protected JiowaTemplateConfig |
config
Contains the template configuration text from the property file.
|
protected static java.lang.String |
JAR_FILE_SUFFIX
File suffix for jar files
|
protected java.util.Set<java.lang.String> |
messages
Set of messages to be printed
|
protected TemplateNotation |
notation
The given template notation
|
protected static int |
NUMBER_OF_TEMPLATE_NAMES_TO_SHOW_IN_LOG_MESSAGE
number of templates to show in log message
|
protected com.jiowa.util.tuple.Tuple<java.io.File,java.util.jar.JarFile> |
resourceLocation
Location for the configuration for the template bean generator
|
protected TemplateMap |
templateMap
TemplateMap for user templates
|
protected java.lang.Boolean |
upToDateFlag
is set to true if timestamps indicate that no re-generation is necessary
|
protected static java.lang.String |
VERSION_FILE_SUFFIX
Suffix for the template bean version file
|
Constructor and Description |
---|
JiowaTemplateBeanGenerator(JiowaTemplateConfig config,
boolean checkTemplateSyntaxOnly)
Basic constructor for the template bean generator: see
JiowaTemplateConfig for usage of the config class. |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
checkProtectedRegionsInTemplates() |
protected TagValueMap |
computeSubTemplateStructureTagMap(SubTemplateStructureTag tag)
Computes the pre-compiled toString()-method text for a subtemplate structure tag.
|
protected TagValueMap |
computeTextOperatorTagMap(TextOperatorTag tag) |
protected TagValueMap |
computeTextTagMap(TextTag tag)
Computes the
TagValueMap for TextTag s |
protected TagValueMap |
computeVariableTagMap(VariableTag tag)
Computes the pre-compiled toString()-method text for variable tag.
|
protected TemplateMapLoader |
createBeanTemplateMapLoader()
Ceates the bean template map loader to load all bean templates for the resource location.
|
protected java.lang.String |
createCommentedErrorsString() |
protected java.lang.String |
createErrorsString() |
protected java.lang.String |
createID(java.lang.String templateName) |
protected java.lang.String |
createMessageString(java.util.List<com.jiowa.logging.LogEntry> list,
java.lang.String prefixString) |
protected java.lang.String |
createWarningsString() |
protected com.jiowa.util.tuple.Tuple<java.io.File,java.util.jar.JarFile> |
determineResourceLocation()
Determines the resource location for the template bean generator configuration.
|
protected java.lang.String |
determineRunningVersion() |
void |
generate()
Generates the template beans.
|
protected java.lang.String |
generateCompileTimeResultClass(Template template) |
protected java.lang.String |
generateTemplateBean(Template template,
java.lang.String packageName)
Generates the text of a template bean out of an template.
|
protected void |
initialize()
Initializes the bean template map.
|
protected boolean |
isUpToDate()
Checks if anything has to be (re-)generated at all.
|
protected TemplateMap |
loadBeanTemplateMap() |
protected TemplateMap |
loadCurrentTemplateMap(TemplateDirs2Package dirs2Package)
Loads the template map for the given template directory set.
|
protected void |
logUniqueErrorMessage(java.lang.String msg)
Logs an error message only if it does not have been logged before.
|
protected boolean |
previousTemplateBeansHaveBeenGeneratedBySameProgramVersion()
Returns true if the already existing template beans have been generated by the same program version
and false, otherwise.
|
protected void |
printSummarizingMessages()
Prints summarizing messages after the generation process.
|
protected void |
processBeanPartInitializer(java.util.List<Tag> list,
TagValueMap map)
Initializes the bean for the toString() method, i.e.
|
protected void |
processSubTemplateStructure(java.lang.String identifier,
java.util.Collection<AbstractSubTemplateTag> subTemplates,
TagValueMap map) |
protected void |
processSubTemplateStructure(SubTemplateStructureTag subStructureTag,
TagValueMap map)
Process a single subtemplate structure, i.e. process all subtemplates
and inline subtemplates and prepare the next recursive call of this method until
all substructures have been processed.
|
protected void |
processSubTemplateStructureList(java.util.List<SubTemplateStructureTag> tagList,
TagValueMap map) |
protected void |
processVariableList(java.util.List<VariableTag> tagList,
TagValueMap map) |
protected void |
writeSource(java.lang.String filePath,
java.lang.String beanText)
Writes the bean text to a file.
|
protected void |
writeVersionFile()
Writes the program version to the bean directory in order to being able to find out which
program version wrote all beans.
|
protected JiowaTemplateConfig config
protected static final java.lang.String BGT
protected static final java.lang.String BEAN_TEMPLATE_FILENAME
protected static final java.lang.String BEAN_TEMPLATE_COMPILER_RESULT_CLASSNAME
protected static final java.lang.String BEAN_TEMPLATE_COMPILER_RESULT_FILENAME
protected Template beanTemplate
protected Template compileTimeResultTemplate
protected java.io.File beanOutputDirectory
protected java.io.File beanOutputDirectoryWithoutPackageName
protected TemplateMap beanTemplateMap
protected TemplateMap templateMap
protected TemplateNotation notation
protected static final int NUMBER_OF_TEMPLATE_NAMES_TO_SHOW_IN_LOG_MESSAGE
protected com.jiowa.util.tuple.Tuple<java.io.File,java.util.jar.JarFile> resourceLocation
protected java.lang.Boolean upToDateFlag
protected java.util.Set<java.lang.String> messages
protected boolean checkTemplateSyntaxOnly
protected static final java.lang.String CHECK_TEMPLATE_SYNTAX_ONLY_CMD
protected static final java.lang.String JAR_FILE_SUFFIX
protected static final java.lang.String VERSION_FILE_SUFFIX
protected static final java.lang.String COMPILER_RESULT_PACKAGE
public JiowaTemplateBeanGenerator(JiowaTemplateConfig config, boolean checkTemplateSyntaxOnly)
JiowaTemplateConfig
for usage of the config class.config
- the configuration for the template bean generationcheckTemplateSyntaxOnly
- a flag if only a syntax has to be performedpublic void generate()
protected abstract void checkProtectedRegionsInTemplates()
protected void printSummarizingMessages()
protected void writeVersionFile()
protected java.lang.String createWarningsString()
protected java.lang.String createErrorsString()
protected java.lang.String createCommentedErrorsString()
protected java.lang.String createMessageString(java.util.List<com.jiowa.logging.LogEntry> list, java.lang.String prefixString)
protected java.lang.String generateCompileTimeResultClass(Template template)
protected java.lang.String determineRunningVersion()
protected java.lang.String generateTemplateBean(Template template, java.lang.String packageName)
template
- the template instancepackageName
- package name for the template beanprotected void processVariableList(java.util.List<VariableTag> tagList, TagValueMap map)
protected void processSubTemplateStructureList(java.util.List<SubTemplateStructureTag> tagList, TagValueMap map)
protected java.lang.String createID(java.lang.String templateName)
protected void processSubTemplateStructure(java.lang.String identifier, java.util.Collection<AbstractSubTemplateTag> subTemplates, TagValueMap map)
protected void processSubTemplateStructure(SubTemplateStructureTag subStructureTag, TagValueMap map)
subStructureTag
- tag for the sub structuremap
- the tag value mapprotected void processBeanPartInitializer(java.util.List<Tag> list, TagValueMap map)
list
- the list of tags to be processedmap
- map with tag to value mappingsprotected TagValueMap computeTextOperatorTagMap(TextOperatorTag tag)
protected TagValueMap computeTextTagMap(TextTag tag)
TagValueMap
for TextTag
stag
- the TextTag
TagValueMap
protected TagValueMap computeVariableTagMap(VariableTag tag)
tag
- the variable tagprotected TagValueMap computeSubTemplateStructureTagMap(SubTemplateStructureTag tag)
tag
- the substructure tagprotected void writeSource(java.lang.String filePath, java.lang.String beanText)
filePath
- the filebeanText
- source code for the beanprotected com.jiowa.util.tuple.Tuple<java.io.File,java.util.jar.JarFile> determineResourceLocation()
protected boolean previousTemplateBeansHaveBeenGeneratedBySameProgramVersion()
protected boolean isUpToDate()
protected TemplateMapLoader createBeanTemplateMapLoader()
protected TemplateMap loadBeanTemplateMap()
protected TemplateMap loadCurrentTemplateMap(TemplateDirs2Package dirs2Package)
dirs2Package
- template directory set to package name mappingprotected void initialize()
protected void logUniqueErrorMessage(java.lang.String msg)
msg
- the message