Class ReportElement

java.lang.Object
org.jacoco.report.internal.xml.XMLElement
org.jacoco.report.internal.xml.ReportElement

public class ReportElement extends XMLElement
A XMLElement with utility methods to create JaCoCo XML reports.
  • Field Details

  • Constructor Details

    • ReportElement

      public ReportElement(String name, OutputStream output, String encoding) throws IOException
      Creates a report root element for a XML report.
      Parameters:
      name - value for the name attribute
      encoding - character encoding used for output
      output - output stream will be closed if the root element is closed
      Throws:
      IOException - in case of problems with the underlying output
    • ReportElement

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

    • element

      public ReportElement 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
    • namedElement

      private ReportElement namedElement(String elementName, String name) throws IOException
      Throws:
      IOException
    • sessioninfo

      public void sessioninfo(SessionInfo info) throws IOException
      Creates a 'sessioninfo' element.
      Parameters:
      info - info object to write out
      Throws:
      IOException - in case of problems with the underlying output
    • group

      public ReportElement group(String name) throws IOException
      Creates a 'group' element.
      Parameters:
      name - value for the name attribute
      Returns:
      'group' element
      Throws:
      IOException - in case of problems with the underlying output
    • packageElement

      public ReportElement packageElement(String name) throws IOException
      Creates a 'package' element.
      Parameters:
      name - value for the name attribute
      Returns:
      'package' element
      Throws:
      IOException - in case of problems with the underlying output
    • classElement

      public ReportElement classElement(IClassCoverage coverage) throws IOException
      Creates a 'class' element.
      Parameters:
      coverage - class coverage node to write out
      Returns:
      'class' element
      Throws:
      IOException - in case of problems with the underlying output
    • method

      public ReportElement method(IMethodCoverage coverage) throws IOException
      Creates a 'method' element.
      Parameters:
      coverage - method coverage node to write out
      Returns:
      'method' element
      Throws:
      IOException - in case of problems with the underlying output
    • sourcefile

      public ReportElement sourcefile(String name) throws IOException
      Creates a 'sourcefile' element.
      Parameters:
      name - value for the name attribute
      Returns:
      'sourcefile' element
      Throws:
      IOException - in case of problems with the underlying output
    • line

      public void line(int nr, ILine line) throws IOException
      Creates a 'line' element.
      Parameters:
      nr - line number
      line - line object to write out
      Throws:
      IOException - in case of problems with the underlying output
    • counter

      public void counter(ICoverageNode.CounterEntity counterEntity, ICounter counter) throws IOException
      Creates a 'counter' element.
      Parameters:
      counterEntity - entity of this counter
      counter - counter object to write out
      Throws:
      IOException - in case of problems with the underlying output
    • counterAttributes

      private static void counterAttributes(XMLElement element, String missedattr, String coveredattr, ICounter counter) throws IOException
      Throws:
      IOException