Class DefaultImporterTool

All Implemented Interfaces:
IChildEngine, ITool, IVariable, Serializable, Cloneable, Observer
Direct Known Subclasses:
DOCXImporterTool

@OpenApiAll public class DefaultImporterTool extends ImportTool
This tool will allow user to import plain text template.
See Also:
  • Constructor Details

    • DefaultImporterTool

      public DefaultImporterTool(ITemplateEngine iTemplateEngine)
      Constructor
  • Method Details

    • importer

      public CharSequence importer(Object importedObject, String importedSectionName)
      Gets the String content of the import object (may be file or path). This will do all the importTool's work. It is called by both public methods, with the difference that section is null if we want to include the whole file. Else it has a section name and only that subsection will be included.
      Parameters:
      importedObject - the imported object that may be string of template path or file of template.
      importedSectionName - if there is a section else this is null
      Returns:
      the evaluated and validated output from childTemplate
    • importer

      public CharSequence importer(String importedTemplateFileName, String importedSectionName)
      Gets the String content of the imported template path. This will do all the importTool's work. It is called by both public methods, with the difference that section is null if we want to include the whole file. Else it has a section name and only that subsection will be included.
      Overrides:
      importer in class ImportTool
      Parameters:
      importedTemplateFileName - the path of childTemplate to be evaluated
      importedSectionName - if there is a section else this is null
      Returns:
      the evaluated and validated output from childTemplate
    • importer

      public CharSequence importer(File importedFile, String importedSectionName)
      Gets the String content of the imported file. This will do all the importTool's work. It is called by both public methods, with the difference that section is null if we want to include the whole file. Else it has a section name and only that subsection will be included.
      Parameters:
      importedFile - the childTemplate file to be evaluated
      importedSectionName - if there is a section else this is null
      Returns:
      the evaluated and validated output from childTemplate
    • setTemplateEngine

      protected ITemplateEngine setTemplateEngine(String fileName)
      This will only create a new TemplateEngine in the case that the previous instance was of a different kind. We can safely assume that within a single document all include/includeSection directives will access templates of the same kind. It will set the IValidator in accord with the engine instance.
      Parameters:
      fileName - the templateFile that determines the engineType
      Returns:
      the Template engine
    • setupEngine

      protected void setupEngine(ITemplateEngine engine)
      Set up engine.
      Add properties and context to engine.
      Parameters:
      engine - current engine
    • getTemplateFile

      protected File getTemplateFile(String templateFileName) throws IOException
      Creates template file from the template file name.
      Parameters:
      templateFileName - the child Template path
      Returns:
      the template file
      Throws:
      IOException
    • getCanonicalTemplate

      protected String getCanonicalTemplate(String templateFileName) throws IOException
      Creates an absolute path from the template file name.
      Parameters:
      templateFileName - the child Template path
      Returns:
      the absolute Path
      Throws:
      IOException - if the canonical file cannot be instantiated.
    • isSupport

      protected boolean isSupport(String engineType)
      CHeck supported engine type
      Parameters:
      engineType - engine type
      Returns:
      true if the specific engine is supported, otherwise; false
    • getEngineType

      protected String getEngineType()
    • setEngineType

      protected void setEngineType(String engineType)