Class TemplateManager

    • Method Detail

      • getFullTemplateContents

        public String getFullTemplateContents​(String name)
        returns the template content by name
        Specified by:
        getFullTemplateContents in interface TemplatingExecutor
        Parameters:
        name - the template name (e.g. model.mustache)
        Returns:
        the contents of that template
      • getFullTemplatePath

        public Path getFullTemplatePath​(String name)
        Returns the path of a template, allowing access to the template where consuming literal contents aren't desirable or possible.
        Specified by:
        getFullTemplatePath in interface TemplatingExecutor
        Parameters:
        name - the template name (e.g. model.mustache)
        Returns:
        The Path to the template
      • getCPResourcePath

        public static String getCPResourcePath​(String name)
        Gets a normalized classpath resource location according to OS-specific file separator
        Parameters:
        name - The name of the resource file/directory to find
        Returns:
        A normalized string according to OS-specific file separator
      • readTemplate

        public String readTemplate​(String name)
        Reads a template's contents from the specified location
        Parameters:
        name - The location of the template
        Returns:
        The raw template contents
      • getTemplateReader

        public Reader getTemplateReader​(String name)
      • writeToFile

        public File writeToFile​(String filename,
                                String contents)
                         throws IOException
        Write String to a file, formatting as UTF-8
        Parameters:
        filename - The name of file to write
        contents - The contents string.
        Returns:
        File representing the written file.
        Throws:
        IOException - If file cannot be written.
      • writeToFile

        public File writeToFile​(String filename,
                                byte[] contents)
                         throws IOException
        Write bytes to a file
        Specified by:
        writeToFile in interface TemplateProcessor
        Parameters:
        filename - The name of file to write
        contents - The contents bytes. Typically, this is a UTF-8 formatted string.
        Returns:
        File representing the written file.
        Throws:
        IOException - If file cannot be written.