Class TemplateParser
java.lang.Object
io.aiven.commons.kafka.connector.common.templating.TemplateParser
A parser for a template
-
Method Summary
Modifier and TypeMethodDescriptioncheckMalformed(String name, String text, TemplateVariableRegistry registry) Checks if a text string may contain malformed templates.static Templateparse(String templatePattern, TemplateVariableRegistry registry) Parses the template.static voidvalidate(String configurationName, String templatePattern, TemplateVariableRegistry registry) Validates that the template string is parsable.
-
Method Details
-
validate
public static void validate(String configurationName, String templatePattern, TemplateVariableRegistry registry) Validates that the template string is parsable.- Parameters:
configurationName- the name of the template string. Generally the name of the configuration option that provided the template. pattern.templatePattern- the template string.registry- the registry of permitted TemplateVariables
-
checkMalformed
public static List<String> checkMalformed(String name, String text, TemplateVariableRegistry registry) Checks if a text string may contain malformed templates. If a valid template is passed it will be returned as potentially malformed.- Parameters:
name- the name of the template configuration option.text- the text that may be an invalid template, should not be a valid template.registry- The TemplateVariableRegistry to validate against. May benull.- Returns:
- A list of log messages indicating the malformed templates.
-
parse
Parses the template.- Parameters:
templatePattern- the template string.registry- the template variable registry.- Returns:
- The parsed template object.
-