public class ReplacementService extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CONTENT_REPLACED |
private static ReplacementService |
instance
Singleton.
|
private static org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
ReplacementService() |
| Modifier and Type | Method and Description |
|---|---|
private boolean |
containsDotInName(String resource) |
List<TemplateResource> |
copyResourcesToTargetDirectory(SubstitutionContext substitutionContext) |
private void |
createDirectoryIfNotExists(File directory) |
private String |
findPlaceholderAndGenerateDiagram(Placeholder placeholder,
SubstitutionContext substitutionContext) |
private String |
generateContent(Placeholder placeholder,
SubstitutionContext substitutionContext)
Depends on
Placeholder.getClassName() use its instance for generation
of placeholder content and replace it. |
static ReplacementService |
getInstance() |
File |
getTargetFile(TemplateResource templateResource,
SubstitutionContext substitutionContext) |
void |
insertContentIntoTemplate(TemplateResource templateResource,
SubstitutionContext substitutionContext)
Load template from the
TemplateResource, collect Placeholders from the template, replace the
Placeholders with generated content and write the template with generated content to a target file. |
private String |
processContentGenerator(Placeholder placeholder,
SubstitutionContext substitutionContext,
Class<? extends ContentGenerator> placeholderClass) |
void |
replace(SubstitutionContext substitutionContext)
Call the
copyResourcesToTargetDirectory(SubstitutionContext) method and then for every
TemplateResource call the insertContentIntoTemplate(TemplateResource, SubstitutionContext) method. |
private String |
replaceContent(TemplateResource templateResource,
List<String> templatePlaceholders,
SubstitutionContext substitutionContext) |
private static final org.slf4j.Logger logger
public static final String CONTENT_REPLACED
private static final ReplacementService instance
public ReplacementService()
public static ReplacementService getInstance()
ReplacementService singleton.public void insertContentIntoTemplate(TemplateResource templateResource, SubstitutionContext substitutionContext)
TemplateResource, collect Placeholders from the template, replace the
Placeholders with generated content and write the template with generated content to a target file.templateResource - source of a template, for example /template/markdown/doc/diagrams.mdsubstitutionContext - the current statepublic File getTargetFile(TemplateResource templateResource, SubstitutionContext substitutionContext)
private String replaceContent(TemplateResource templateResource, List<String> templatePlaceholders, SubstitutionContext substitutionContext)
private String generateContent(Placeholder placeholder, SubstitutionContext substitutionContext)
Placeholder.getClassName() use its instance for generation
of placeholder content and replace it.placeholder - contains a Placeholder.getClassName()substitutionContext - the current stateReportDocumentCreator return for example
tag.
In case of ContentGenerator return a generated content.
private String processContentGenerator(Placeholder placeholder, SubstitutionContext substitutionContext, Class<? extends ContentGenerator> placeholderClass)
private String findPlaceholderAndGenerateDiagram(Placeholder placeholder, SubstitutionContext substitutionContext)
private void createDirectoryIfNotExists(File directory)
public void replace(SubstitutionContext substitutionContext)
copyResourcesToTargetDirectory(SubstitutionContext) method and then for every
TemplateResource call the insertContentIntoTemplate(TemplateResource, SubstitutionContext) method.substitutionContext - the current state.public List<TemplateResource> copyResourcesToTargetDirectory(SubstitutionContext substitutionContext)
private boolean containsDotInName(String resource)
resource - for example '/template/markdown/' is a directory, and '/template/markdown/README.md' is a file.Copyright © 2023. All rights reserved.