Interface Engine

All Superinterfaces:
ErrorInitializer

public interface Engine extends ErrorInitializer
Represents a central point for template management.

It has a dedicated configuration and is able to cache the template definitions.

See Also:
  • Method Details

    • builder

      static EngineBuilder builder()
      Returns:
      a new builder instance
    • parse

      default Template parse(String content)
      Parse the template contents.

      Note that this method always returns a new Template instance.

      Parameters:
      content -
      Returns:
      the template
    • parse

      default Template parse(String content, Variant variant)
      Parse the template contents with the specified variant.

      Note that this method always returns a new Template instance.

      Parameters:
      content -
      variant -
      Returns:
      the template
    • parse

      Template parse(String content, Variant variant, String id)
      Parse the template contents with the specified variant and id.

      Note that this method always returns a new Template instance.

      Parameters:
      content -
      variant -
      id -
      Returns:
      the template
    • getResultMappers

      List<ResultMapper> getResultMappers()
      Returns:
      an immutable list of result mappers
    • mapResult

      String mapResult(Object result, Expression expression)
      Maps the given result to a string value. If no result mappers are available the Object.toString() value is used.
      Parameters:
      result - Must not be null
      expression - Must not be null
      Returns:
      the string value
      See Also:
    • putTemplate

      Template putTemplate(String id, Template template)
      Parameters:
      id -
      template -
      Returns:
      the previous value or null
    • getTemplate

      Template getTemplate(String id)
      Obtain a template for the given identifier. A template may be registered using putTemplate(String, Template) or loaded by a template locator.
      Parameters:
      id -
      Returns:
      the template or null
      See Also:
    • isTemplateLoaded

      boolean isTemplateLoaded(String id)
      Note that template locators are not used in this method.
      Parameters:
      id -
      Returns:
      true if a template with the given identifier is loaded, false otherwise
    • clearTemplates

      void clearTemplates()
      Removes all templates from the cache.
    • removeTemplates

      void removeTemplates(Predicate<String> test)
      Removes the templates for which the mapping id matches the given predicate.
      Parameters:
      test -
    • getSectionHelperFactory

      SectionHelperFactory<?> getSectionHelperFactory(String name)
      Parameters:
      name -
      Returns:
      the section helper factory for the giben name
    • getSectionHelperFactories

      Map<String,SectionHelperFactory<?>> getSectionHelperFactories()
      Returns:
      an immutable map of section helper factories
    • getValueResolvers

      List<ValueResolver> getValueResolvers()
      Returns:
      an immutable list of value resolvers
    • getNamespaceResolvers

      List<NamespaceResolver> getNamespaceResolvers()
      Returns:
      an immutable list of namespace resolvers
    • getEvaluator

      Evaluator getEvaluator()
      Returns:
      the evaluator used to evaluate expressions
    • getTemplateInstanceInitializers

      List<TemplateInstance.Initializer> getTemplateInstanceInitializers()
      Returns:
      an immutable list of template instance initializers
    • getTimeout

      long getTimeout()
      The global rendering timeout in milliseconds. It is used if no timeout instance attribute is set.
      Returns:
      the global rendering timeout
      See Also:
    • useAsyncTimeout

      boolean useAsyncTimeout()
      Returns:
      true if the timeout should also used for asynchronous rendering methods
    • locate

      Locates the template with the given id.

      All locators registered via EngineBuilder.addLocator(TemplateLocator) are used.

      Parameters:
      id -
      Returns:
      the template location for the given id, or an empty Optional if no template was found
      See Also:
    • removeStandaloneLines

      boolean removeStandaloneLines()
      Returns:
      true if the parser should remove standalone lines from the output, false otherwise
    • newBuilder

      EngineBuilder newBuilder()
      Returns:
      a new builder instance initialized from this engine