Class AbstractMavenReportRenderer

  • All Implemented Interfaces:
    org.apache.maven.reporting.MavenReportRenderer

    public abstract class AbstractMavenReportRenderer
    extends java.lang.Object
    implements org.apache.maven.reporting.MavenReportRenderer

    An abstract class to manage report generation, with many helper methods to ease the job: you just need to implement getTitle() and renderBody().

    TODO Later it may be appropriate to create something like a VelocityMavenReportRenderer that could take a velocity template and pipe that through Doxia rather than coding them up like this.

    Since:
    2.0
    Author:
    Jason van Zyl, Emmanuel Venisse, Vincent Siveton
    See Also:
    getTitle(), renderBody()
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.maven.doxia.sink.Sink sink
      The current sink to use
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractMavenReportRenderer​(org.apache.maven.doxia.sink.Sink sink)
      Default constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected static java.lang.String createLinkPatternedText​(java.lang.String text, java.lang.String href)
      Create a link pattern text defined by {text, url}.
      protected void endSection()
      Convenience method to wrap section ending in the current sink.
      protected void endTable()
      Convenience method to wrap the table ending in the current sink.
      abstract java.lang.String getTitle()  
      protected void javaScript​(java.lang.String jsCode)
      Convenience method to add a Javascript code in the current sink.
      protected void link​(java.lang.String href, java.lang.String name)
      Convenience method to wrap a link in the current sink.
      void linkPatternedText​(java.lang.String text)
      Convenience method to wrap a patterned text in the current link.
      protected void paragraph​(java.lang.String paragraph)
      Convenience method to wrap a paragraph in the current sink.
      protected static java.lang.String propertiesToString​(java.util.Properties props)
      Convenience method to display a Properties object as comma separated String.
      void render()
      protected abstract void renderBody()
      Renderer the body content of the report.
      protected void startSection​(java.lang.String name)
      Convenience method to wrap section creation in the current sink.
      protected void startSection​(java.lang.String name, java.lang.String anchor)
      Convenience method to wrap section creation in the current sink.
      protected void startTable()
      Convenience method to wrap the table start in the current sink.
      protected void startTable​(int[] justification, boolean grid)
      Convenience method to wrap the table start in the current sink.
      protected void tableCaption​(java.lang.String caption)
      Convenience method to wrap a table caption in the current sink.
      protected void tableCell​(java.lang.String text)
      Convenience method to wrap a table cell start in the current sink.
      protected void tableCell​(java.lang.String text, boolean asHtml)
      Convenience method to wrap a table cell start in the current sink.
      protected void tableHeader​(java.lang.String[] content)
      Convenience method to wrap a table header row start in the current sink.
      protected void tableHeaderCell​(java.lang.String text)
      Convenience method to wrap the table header cell start in the current sink.
      protected void tableRow​(java.lang.String[] content)
      Convenience method to wrap a table row start in the current sink.
      protected void text​(java.lang.String text)
      Convenience method to wrap a text in the current sink.
      protected void verbatimLink​(java.lang.String text, java.lang.String href)
      Convenience method to wrap a text with a given link href as verbatim style in the current sink.
      protected void verbatimSource​(java.lang.String source)
      Convenience method to wrap source code as verbatim style in the current sink .
      protected void verbatimText​(java.lang.String text)
      Convenience method to wrap a text as verbatim style in the current sink .
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • sink

        protected org.apache.maven.doxia.sink.Sink sink
        The current sink to use
    • Constructor Detail

      • AbstractMavenReportRenderer

        public AbstractMavenReportRenderer​(org.apache.maven.doxia.sink.Sink sink)
        Default constructor.
        Parameters:
        sink - the sink to use.
    • Method Detail

      • render

        public void render()
        Specified by:
        render in interface org.apache.maven.reporting.MavenReportRenderer
      • startSection

        protected void startSection​(java.lang.String name)
        Convenience method to wrap section creation in the current sink. An anchor will be derived from the name.
        Parameters:
        name - the name of this section, could be null.
        See Also:
        text(String), Sink.section(int, org.apache.maven.doxia.sink.SinkEventAttributes), Sink.sectionTitle(int, org.apache.maven.doxia.sink.SinkEventAttributes), Sink.sectionTitle_(int)
      • startSection

        protected void startSection​(java.lang.String name,
                                    java.lang.String anchor)
        Convenience method to wrap section creation in the current sink.
        Parameters:
        name - the name of this section, could be null.
        anchor - the anchor of this section, could be null.
        See Also:
        text(String), Sink.section(int, org.apache.maven.doxia.sink.SinkEventAttributes), Sink.sectionTitle(int, org.apache.maven.doxia.sink.SinkEventAttributes), Sink.sectionTitle_(int)
      • endSection

        protected void endSection()
        Convenience method to wrap section ending in the current sink.
        Throws:
        java.lang.IllegalStateException - if too many closing sections.
        See Also:
        Sink.section_(int)
      • startTable

        protected void startTable()
        Convenience method to wrap the table start in the current sink.
        See Also:
        Sink.table()
      • startTable

        protected void startTable​(int[] justification,
                                  boolean grid)
        Convenience method to wrap the table start in the current sink.
        Parameters:
        justification - the justification of table cells.
        grid - whether to draw a grid around cells.
        Since:
        2.1
        See Also:
        Sink.table(), Sink.tableRows(int[],boolean)
      • endTable

        protected void endTable()
        Convenience method to wrap the table ending in the current sink.
        See Also:
        Sink.table_()
      • tableHeaderCell

        protected void tableHeaderCell​(java.lang.String text)
        Convenience method to wrap the table header cell start in the current sink.
        Parameters:
        text - the text to put in this cell, could be null.
        See Also:
        text(String), Sink.tableHeaderCell(), Sink.tableHeaderCell_()
      • tableCell

        protected void tableCell​(java.lang.String text)
        Convenience method to wrap a table cell start in the current sink.

        The text could be a link patterned text defined by {text, url}

        Parameters:
        text - the text to put in this cell, could be null.
        See Also:
        linkPatternedText(String), tableCell(String)
      • tableCell

        protected void tableCell​(java.lang.String text,
                                 boolean asHtml)
        Convenience method to wrap a table cell start in the current sink.

        The text could be a link patterned text defined by {text, url}

        If asHtml is true, add the text as Html

        Parameters:
        text - the text to put in this cell, could be null.
        asHtml - true to add the text as Html, false otherwise.
        See Also:
        linkPatternedText(String), Sink.tableCell(), Sink.tableCell_(), Sink.rawText(String)
      • tableRow

        protected void tableRow​(java.lang.String[] content)
        Convenience method to wrap a table row start in the current sink.

        The texts in the content could be link patterned texts defined by {text, url}

        Parameters:
        content - an array of text to put in the cells in this row, could be null.
        See Also:
        tableCell(String), Sink.tableRow(), Sink.tableRow_()
      • tableHeader

        protected void tableHeader​(java.lang.String[] content)
        Convenience method to wrap a table header row start in the current sink.
        Parameters:
        content - an array of text to put in the cells in this row header, could be null.
        See Also:
        tableHeaderCell(String), Sink.tableRow(), Sink.tableRow_()
      • tableCaption

        protected void tableCaption​(java.lang.String caption)
        Convenience method to wrap a table caption in the current sink.
        Parameters:
        caption - the caption of the table, could be null.
        See Also:
        text(String), Sink.tableCaption(), Sink.tableCaption_()
      • paragraph

        protected void paragraph​(java.lang.String paragraph)
        Convenience method to wrap a paragraph in the current sink.
        Parameters:
        paragraph - the paragraph to add, could be null.
        See Also:
        text(String), Sink.paragraph(), Sink.paragraph_()
      • link

        protected void link​(java.lang.String href,
                            java.lang.String name)
        Convenience method to wrap a link in the current sink.
        Parameters:
        href - the link to add, cannot be null.
        name - the link name.
        See Also:
        text(String), Sink.link(String), Sink.link_()
      • text

        protected void text​(java.lang.String text)
        Convenience method to wrap a text in the current sink.

        If text is empty or has a null value, add the "-" character

        Parameters:
        text - a text, could be null.
        See Also:
        Sink.text(String)
      • verbatimText

        protected void verbatimText​(java.lang.String text)
        Convenience method to wrap a text as verbatim style in the current sink .
        Parameters:
        text - a text, could be null.
        See Also:
        text(String), Sink.verbatim(org.apache.maven.doxia.sink.SinkEventAttributes), Sink.verbatim_()
      • verbatimLink

        protected void verbatimLink​(java.lang.String text,
                                    java.lang.String href)
        Convenience method to wrap a text with a given link href as verbatim style in the current sink.
        Parameters:
        text - a string
        href - an href could be null
        See Also:
        link(String, String), verbatimText(String), Sink.verbatim(org.apache.maven.doxia.sink.SinkEventAttributes), Sink.verbatim_()
      • verbatimSource

        protected void verbatimSource​(java.lang.String source)
        Convenience method to wrap source code as verbatim style in the current sink .
        Parameters:
        source - a source code, could be null.
        See Also:
        text(String), Sink.verbatim(org.apache.maven.doxia.sink.SinkEventAttributes), Sink.verbatim_()
      • javaScript

        protected void javaScript​(java.lang.String jsCode)
        Convenience method to add a Javascript code in the current sink.
        Parameters:
        jsCode - a string of Javascript
        See Also:
        Sink.rawText(String)
      • linkPatternedText

        public void linkPatternedText​(java.lang.String text)
        Convenience method to wrap a patterned text in the current link.

        The text variable should contained this given pattern {text, url} to handle the link creation.

        Parameters:
        text - a text with link pattern defined.
        See Also:
        text(String), link(String, String), applyPattern(String)
      • createLinkPatternedText

        protected static java.lang.String createLinkPatternedText​(java.lang.String text,
                                                                  java.lang.String href)
        Create a link pattern text defined by {text, url}.

        This created pattern could be used by the method linkPatternedText(String) to handle a text with link.

        Parameters:
        text -
        href -
        Returns:
        a link pattern
        See Also:
        linkPatternedText(String)
      • propertiesToString

        protected static java.lang.String propertiesToString​(java.util.Properties props)
        Convenience method to display a Properties object as comma separated String.
        Parameters:
        props - the properties to display.
        Returns:
        the properties object as comma separated String
      • getTitle

        public abstract java.lang.String getTitle()
        Specified by:
        getTitle in interface org.apache.maven.reporting.MavenReportRenderer
      • renderBody

        protected abstract void renderBody()
        Renderer the body content of the report.