java.lang.Object
org.matwoess.jsourceprofiler.tool.profile.AbstractHtmlWriter
Direct Known Subclasses:
ReportClassIndexWriter, ReportMethodIndexWriter, ReportSourceWriter

public abstract class AbstractHtmlWriter extends Object
The abstract superclass for all HTML writers.

Contains common methods to generate parts of an HTML document and write them to a file.

Subclasses should implement the body() method to generate the main content of the HTML document.

The fields title, includeScripts, bodyScripts and cssFiles can be used to customize the HTML document.

The getFileOutputPath() method should be overridden to return the path to where the output file should be written to.

  • Field Details

    • title

      public String title
    • includeScripts

      public String[] includeScripts
    • bodyScripts

      public String[] bodyScripts
    • cssFiles

      public String[] cssFiles
  • Constructor Details

    • AbstractHtmlWriter

      public AbstractHtmlWriter()
  • Method Details

    • header

      public void header()
      Appends the HTML header to the internal content StringBuilder.

      Includes the doctype, the html and head tags, the title, the included scripts and the css style.

    • bodyStart

      public void bodyStart()
      Appends the HTML body start tag to the internal content StringBuilder.
    • heading

      public void heading(String heading)
      Writes the custom heading to the internal content StringBuilder.
      Parameters:
      heading - the page title string
    • body

      public abstract void body()
      Should be overridden to generate the main content of the HTML document.
    • bodyEnd

      public void bodyEnd()
      Appends the HTML body end tag to the internal content StringBuilder and includes all the body scripts.
    • generate

      public void generate()
      Generates the full HTML document out of all helper methods.
    • write

      public void write()
      Writes the generated HTML document to the file specified by getFileOutputPath().

      Parent directories are created if they do not exist.

    • getFileOutputPath

      public abstract Path getFileOutputPath()
      Returns the path to where the output file should be written to. Should be overridden by subclasses.
      Returns:
      the destination path of the output file