Class TemplateEngineFactory

java.lang.Object
com.nomagic.magicreport.TemplateEngineFactory

@OpenApiAll public final class TemplateEngineFactory extends Object
This is the factory for template engine. It is the single access point for all functionality. It applied the singleton pattern.
Since:
Jun 12, 2007 12:23:05 AM
Version:
1.0 Jun 12, 2007
  • Method Details

    • getInstance

      public static TemplateEngineFactory getInstance()
      Return instance of this class.
      Returns:
      instance of this class.
    • getDefaultTemplateEngineClassName

      public String getDefaultTemplateEngineClassName(String engineName)
      Return default template engine class name.
      Parameters:
      engineName - name.
      Returns:
      default template engine class name.
    • getTemplateAliasNames

      public String[] getTemplateAliasNames()
      Return an array of the alias names of default template engine.
       
              String[] aliasNames = TemplateEngineFactory.getInstance().getTemplateAliasNames();
       
       
      Returns:
      an array of the alias names and description
    • registerTemplateEngine

      public void registerTemplateEngine(String extension, Class<? extends ITemplateEngine> templateEngineClass)
      Registers the given class name with the TemplateEngineFactory. A newly-loaded engine class should call the method registerTemplateEngine to make itself known to the TemplateEngineFactory.
      Parameters:
      extension - template file extension
      templateEngineClass - the new ITemplateEngine that is to be registered with the TemplateEngineFactory
    • unregisterTemplateEngine

      public void unregisterTemplateEngine(String extension)
      Unregister the given file extension.
      Parameters:
      extension - file extension.
    • getRegisterTemplateEngine

      public Class<? extends ITemplateEngine> getRegisterTemplateEngine(String extension)
      Return a registered template engine class.
      Parameters:
      extension - template file extension
      Returns:
      a template engine class ITemplateEngine
    • getTemplateEngine

      public ITemplateEngine getTemplateEngine(Class<? extends ITemplateEngine> clazz) throws InitializationEngineException
      Return template engine associated with given class or create a new instance if it doesn't created.
      Parameters:
      clazz - associated class for template engine.
      Returns:
      template engine
      Throws:
      InitializationEngineException - error while creating template engine.
    • getTemplateEngine

      public ITemplateEngine getTemplateEngine(String type) throws InitializationEngineException
      Return template engine associated with given type or create a new instance if it doesn't created. If no associated type found, text engine TextEngine will be return as default engine.
      Parameters:
      type - engine type.
      Returns:
      template engine
      Throws:
      InitializationEngineException - error while creating template engine.
    • getTemplateEngineClass

      public Class<? extends ITemplateEngine> getTemplateEngineClass(String type)
      Return class of template engine associated with given type. If no associated type found, text engine TextEngine will be return as default engine.
      Parameters:
      type - engine type.
      Returns:
      template engine class
    • createTemplateEngine

      public ITemplateEngine createTemplateEngine(String type) throws InitializationEngineException
      Create a new instance of template engine associated with given type. If no associated type found, text engine TextEngine will be return as default engine.

      This method always return new instance.

      Parameters:
      type - engine type.
      Returns:
      template engine
      Throws:
      InitializationEngineException - error while creating template engine.
    • createTemplateEngine

      public ITemplateEngine createTemplateEngine(Class<? extends ITemplateEngine> clazz) throws InitializationEngineException
      Create a new instance of template engine associated with given class.

      This method always return new instance.

      Parameters:
      clazz - engine Class.
      Returns:
      template engine
      Throws:
      InitializationEngineException - error while creating template engine.
    • copy

      public void copy(ITemplateEngine dest, ITemplateEngine source)
      Copies all properties and context from source engine to destination engine.

      This method will perform shallow copy of context. The reference to context of new engine will not remain the same as source engine. In order to copy, all object inside context requires implement clone() method.

      Parameters:
      dest - the destination engine.
      source - source engine.
    • copy

      public void copy(ITemplateEngine dest, ITemplateEngine source, boolean copyRuntimeInstance, boolean copyFormatterRuntimeInstance)
      Copies all properties and context from source engine to destination engine.

      This method will perform shallow copy of context. The reference to context of new engine will not remain the same as source engine. In order to copy, all object inside context requires implement clone() method.

      Parameters:
      dest - the destination engine.
      source - source engine.
      copyRuntimeInstance - true to copy RuntimeInstance of source to destination engine if both are instance of IRuntimeInstanceVelocityEngine
      copyFormatterRuntimeInstance - true to copy Formatter of source to destination engine if both are instance of DefaultTemplateEngine