Class FreeMarkerWritable

  • All Implemented Interfaces:
    Writable
    Direct Known Subclasses:
    ModelElement

    public abstract class FreeMarkerWritable
    extends Object
    implements Writable
    A Writable which uses the FreeMarker template engine to generate the output.
    Author:
    Gunnar Morling
    • Constructor Detail

      • FreeMarkerWritable

        public FreeMarkerWritable()
    • Method Detail

      • write

        public void write​(Writable.Context context,
                          Writer writer)
                   throws Exception
        Description copied from interface: Writable
        Writes this element to the given writer.
        Specified by:
        write in interface Writable
        Parameters:
        context - Provides additional data specific to the used implementation of the serialization mechanism.
        writer - The writer to write this element to. Must not be closed by implementations.
        Throws:
        Exception - in case of an error
      • getTemplateName

        protected String getTemplateName()
        Returns the name of the template to be used for a specific writable type. By default, getTemplateNameForClass(Class) is called with getClass(), but this can be customized by overriding this method if required.
        Returns:
        the name of the template. Must not be null.
      • getTemplateNameForClass

        protected String getTemplateNameForClass​(Class<?> clazz)
        Returns the name of the template to be used for a specific writable type. By default, the package directory and the class name of the given model element type, appended with the extension *.ftl is used as template file name.
        Parameters:
        clazz - class to obtain a template for
        Returns:
        the name of the template. Must not be null.