|
25 | 25 | * handling of context data and private attribute redaction is implemented in EventContextFormatter |
26 | 26 | * and tested in more detail in EventContextFormatterTest. |
27 | 27 | */ |
28 | | -final class EventOutputFormatter { |
| 28 | +public final class EventOutputFormatter { |
29 | 29 | private final EventContextFormatter contextFormatter; |
30 | 30 | private final boolean redactAnonymousAllEvents; |
31 | 31 |
|
32 | | - EventOutputFormatter(EventsConfiguration config) { |
| 32 | + /** |
| 33 | + * Creates an instance. |
| 34 | + * |
| 35 | + * @param config the events configuration; only the private-attribute settings affect the output |
| 36 | + */ |
| 37 | + public EventOutputFormatter(EventsConfiguration config) { |
33 | 38 | this.contextFormatter = new EventContextFormatter( |
34 | 39 | config.allAttributesPrivate, |
35 | 40 | config.privateAttributes.toArray(new AttributeRef[config.privateAttributes.size()])); |
36 | 41 | this.redactAnonymousAllEvents = config.redactAnonymousAllEvents; |
37 | 42 | } |
38 | 43 |
|
39 | | - int writeOutputEvents(Event[] events, List<EventSummarizer.EventSummary> summaries, Writer writer) throws IOException { |
| 44 | + /** |
| 45 | + * Writes events and summaries as the JSON array that makes up a request body. |
| 46 | + * |
| 47 | + * @param events the individual events to write |
| 48 | + * @param summaries the summaries to write; empty ones are skipped |
| 49 | + * @param writer where to write the JSON |
| 50 | + * @return how many output events were written, counting each summary as one |
| 51 | + * @throws IOException if the writer failed |
| 52 | + */ |
| 53 | + public int writeOutputEvents(Event[] events, List<EventSummarizer.EventSummary> summaries, Writer writer) |
| 54 | + throws IOException { |
40 | 55 | int count = 0; |
41 | 56 | JsonWriter jsonWriter = new JsonWriter(writer); |
42 | 57 | jsonWriter.beginArray(); |
|
0 commit comments