Class HTMLElement

java.lang.Object
org.jacoco.report.internal.xml.XMLElement
org.jacoco.report.internal.html.HTMLElement

public class HTMLElement extends XMLElement
A XMLElement with utility methods to create XHTML documents. It provides methods of HTML tags to avoid magic strings in the generators.
  • Field Details

  • Constructor Details

    • HTMLElement

      public HTMLElement(OutputStream output, String encoding) throws IOException
      Creates a html root element of a XHTML document.
      Parameters:
      output - output stream will be closed if the root element is closed
      encoding - character encoding used for output
      Throws:
      IOException - in case of problems with the underlying output
    • HTMLElement

      private HTMLElement(String name, HTMLElement parent) throws IOException
      Throws:
      IOException
  • Method Details

    • element

      public HTMLElement element(String name) throws IOException
      Description copied from class: XMLElement
      Creates a new child element for this element. Might be overridden in subclasses to return a instance of the subclass.
      Overrides:
      element in class XMLElement
      Parameters:
      name - name of the child element
      Returns:
      child element instance
      Throws:
      IOException - in case of problems with the underlying output
    • classattr

      private void classattr(String classattr) throws IOException
      Throws:
      IOException
    • head

      public HTMLElement head() throws IOException
      Creates a 'head' element.
      Returns:
      'head' element
      Throws:
      IOException - in case of problems with the underlying output
    • body

      public HTMLElement body() throws IOException
      Creates a 'body' element.
      Returns:
      'body' element
      Throws:
      IOException - in case of problems with the underlying output
    • meta

      public HTMLElement meta(String httpequivattr, String contentattr) throws IOException
      Creates a 'meta' element.
      Parameters:
      httpequivattr - value of the http-equiv attribute
      contentattr - value for the content attribute
      Returns:
      'meta' element
      Throws:
      IOException - in case of problems with the underlying output
    • link

      public HTMLElement link(String relattr, String hrefattr, String typeattr) throws IOException
      Creates a 'link' element.
      Parameters:
      relattr - value of the rel attribute
      hrefattr - value for the href attribute
      typeattr - value for the type attribute
      Returns:
      'link' element
      Throws:
      IOException - in case of problems with the underlying output
    • title

      public HTMLElement title() throws IOException
      Creates a 'title' element.
      Returns:
      'title' element
      Throws:
      IOException - in case of problems with the underlying output
    • h1

      public HTMLElement h1() throws IOException
      Creates a 'h1' element.
      Returns:
      'h1' element
      Throws:
      IOException - in case of problems with the underlying output
    • p

      public HTMLElement p() throws IOException
      Creates a 'p' element.
      Returns:
      'p' element
      Throws:
      IOException - in case of problems with the underlying output
    • span

      public HTMLElement span() throws IOException
      Creates a 'span' element.
      Returns:
      'span' element
      Throws:
      IOException - in case of problems with the underlying output
    • span

      public HTMLElement span(String classattr) throws IOException
      Creates a 'span' element.
      Parameters:
      classattr - value of the class attribute
      Returns:
      'span' element
      Throws:
      IOException - in case of problems with the underlying output
    • span

      public HTMLElement span(String classattr, String idattr) throws IOException
      Creates a 'span' element.
      Parameters:
      classattr - value of the class attribute
      idattr - value of the id attribute
      Returns:
      'span' element
      Throws:
      IOException - in case of problems with the underlying output
    • div

      public HTMLElement div(String classattr) throws IOException
      Creates a 'div' element.
      Parameters:
      classattr - value of the class attribute
      Returns:
      'div' element
      Throws:
      IOException - in case of problems with the underlying output
    • code

      public HTMLElement code() throws IOException
      Creates a 'code' element.
      Returns:
      'code' element
      Throws:
      IOException - in case of problems with the underlying output
    • pre

      public HTMLElement pre(String classattr) throws IOException
      Creates a 'pre' element.
      Parameters:
      classattr - value of the class attribute
      Returns:
      'pre' element
      Throws:
      IOException - in case of problems with the underlying output
    • a

      public HTMLElement a(String hrefattr) throws IOException
      Creates a 'a' element.
      Parameters:
      hrefattr - value of the href attribute
      Returns:
      'a' element
      Throws:
      IOException - in case of problems with the underlying output
    • a

      public HTMLElement a(String hrefattr, String classattr) throws IOException
      Creates a 'a' element.
      Parameters:
      hrefattr - value of the href attribute
      classattr - value of the class attribute
      Returns:
      'a' element
      Throws:
      IOException - in case of problems with the underlying output
    • a

      public HTMLElement a(ILinkable linkable, ReportOutputFolder base) throws IOException
      Creates a link to the given ILinkable.
      Parameters:
      linkable - object to link to
      base - base folder where the link should be placed
      Returns:
      'a' element or 'span' element, if the link target does not exist
      Throws:
      IOException - in case of problems with the underlying output
    • table

      public HTMLElement table(String classattr) throws IOException
      Creates a 'table' element.
      Parameters:
      classattr - value of the class attribute
      Returns:
      'table' element
      Throws:
      IOException - in case of problems with the underlying output
    • thead

      public HTMLElement thead() throws IOException
      Creates a 'thead' element.
      Returns:
      'thead' element
      Throws:
      IOException - in case of problems with the underlying output
    • tfoot

      public HTMLElement tfoot() throws IOException
      Creates a 'tfoot' element.
      Returns:
      'tfoot' element
      Throws:
      IOException - in case of problems with the underlying output
    • tbody

      public HTMLElement tbody() throws IOException
      Creates a 'tbody' element.
      Returns:
      'tbody' element
      Throws:
      IOException - in case of problems with the underlying output
    • tr

      public HTMLElement tr() throws IOException
      Creates a 'tr' element.
      Returns:
      'tr' element
      Throws:
      IOException - in case of problems with the underlying output
    • td

      public HTMLElement td() throws IOException
      Creates a 'td' element.
      Returns:
      'td' element
      Throws:
      IOException - in case of problems with the underlying output
    • td

      public HTMLElement td(String classattr) throws IOException
      Creates a 'td' element.
      Parameters:
      classattr - value of the class attribute
      Returns:
      'td' element
      Throws:
      IOException - in case of problems with the underlying output
    • img

      public void img(String srcattr, int widthattr, int heightattr, String titleattr) throws IOException
      Creates a 'img' element.
      Parameters:
      srcattr - value of the src attribute
      widthattr - value of the width attribute
      heightattr - value of the height attribute
      titleattr - value of the title and alt attribute
      Throws:
      IOException - in case of problems with the underlying output
    • script

      public void script(String srcattr) throws IOException
      Creates a JavaScript 'script' element.
      Parameters:
      srcattr - value of the src attribute
      Throws:
      IOException - in case of problems with the underlying output