# Class JsonOutputReporter

java.lang.Object
uk.ac.starlink.ttools.taplint.JsonOutputReporter

All Implemented Interfaces:
  `OutputReporter, Reporter`

public class JsonOutputReporter extends Object implements OutputReporter
OutputReporter implementation for exporting JSON structured output.

Since:
  23 Oct 2016
Author:
  Mark Taylor

## Constructor Summary

Constructors
Constructor
Description
`JsonOutputReporter(PrintStream out, ReportType[] types, int maxRepeat, boolean debug, int maxChar)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`end()`
Signals end of reporting.
`void`
`endSection()`
Ends the current section.
`String`
`getSectionCode()`
Returns the section code for the most recently-started section.
`void`
`report(ReportCode code, String message)`
Reports a message.
`void`
`report(ReportCode code, String message, Throwable err)`
Reports a message with an associated throwable.
`void`
`start(String[] announcements)`
Signals beginning of reporting.
`void`
`startSection(String scode, String message)`
Begins a reporting section.
`void`
`summariseUnreportedMessages(String scode)`
Writes to the output stream a summary of messages which were suppressed in a given stage because the maximum repeat count was exceeded.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### JsonOutputReporter

public JsonOutputReporter(PrintStream out, ReportType[] types, int maxRepeat, boolean debug, int maxChar)
Constructor.

Parameters:
  `out` - destination stream
  `types` - message types to report; others are discarded
  `maxRepeat` - maximum number of times any given message may be repeated; subsequent instances are suppressed
  `debug` - true iff you want to see full stacktraces for exceptions etc
  `maxChar` - maximum number of total characters per line of output

## Method Details

### start

public void start(String[] announcements)
Description copied from interface: `OutputReporter`
Signals beginning of reporting.

Specified by:
  `start` in interface `OutputReporter`
Parameters:
  `announcements` - header information about validator operation; plain text, one line per element

### end

public void end()
Description copied from interface: `OutputReporter`
Signals end of reporting.

Specified by:
  `end` in interface `OutputReporter`

### startSection

public void startSection(String scode, String message)
Description copied from interface: `OutputReporter`
Begins a reporting section.

Specified by:
  `startSection` in interface `OutputReporter`
Parameters:
  `scode` - short fixed-length (3-char?) identifier for the section about to start
  `message` - terse (one-line) free-text description of the stage

### endSection

public void endSection()
Description copied from interface: `OutputReporter`
Ends the current section.

Specified by:
  `endSection` in interface `OutputReporter`

### getSectionCode

public String getSectionCode()
Description copied from interface: `OutputReporter`
Returns the section code for the most recently-started section.

Specified by:
  `getSectionCode` in interface `OutputReporter`
Returns:
  current section code

### report

public void report(ReportCode code, String message)
Description copied from interface: `Reporter`
Reports a message.

This convenience method is equivalent to calling `report(code,message,null)`

Specified by:
  `report` in interface `Reporter`
Parameters:
  `code` - report code; messages with the same code should identify essentially the same condition
  `message` - free-text message; it may be multi-line and/or longish, but may in practice be truncated on output

### report

public void report(ReportCode code, String message, Throwable err)
Description copied from interface: `Reporter`
Reports a message with an associated throwable.

Specified by:
  `report` in interface `Reporter`
Parameters:
  `code` - report code; messages with the same code should identify essentially the same condition
  `message` - free-text message; it may be multi-line and/or longish, but may in practice be truncated on output
  `err` - throwable

### summariseUnreportedMessages

public void summariseUnreportedMessages(String scode)
Description copied from interface: `OutputReporter`
Writes to the output stream a summary of messages which were suppressed in a given stage because the maximum repeat count was exceeded.

Specified by:
  `summariseUnreportedMessages` in interface `OutputReporter`
Parameters:
  `scode` - section code to summarise; if null, no stage filtering is done