Class OutputEmitter
This class centralizes all output rendering logic for the MethodAtlas application. It supports both CSV and plain-text output modes and handles optional AI enrichment columns.
The PrintWriter supplied at construction time is the sole output
destination, which allows the caller to redirect output for testing or
piping without manipulating System.out.
Instances of this class are immutable after construction.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOutputEmitter(PrintWriter out, boolean aiEnabled, boolean confidenceEnabled, boolean contentHashEnabled, boolean driftDetect, boolean emitSourceRoot) Creates a new output emitter bound to the supplied writer. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringEscapes a value for inclusion in a CSV field.voidemit(OutputMode mode, String fqcn, String method, int loc, String contentHash, List<String> tags, String displayName, AiMethodSuggestion suggestion, String sourceRoot) Emits a single test method record in the configured output mode.voidemitCsvHeader(OutputMode mode) Emits the CSV header line whenOutputMode.CSVis selected.voidemitMetadata(String version, String scanTimestamp, String taxonomyInfo) Emits# key: valuemetadata comment lines before the CSV header.
-
Constructor Details
-
OutputEmitter
public OutputEmitter(PrintWriter out, boolean aiEnabled, boolean confidenceEnabled, boolean contentHashEnabled, boolean driftDetect, boolean emitSourceRoot) Creates a new output emitter bound to the supplied writer.- Parameters:
out- writer to which all records are emittedaiEnabled- whether AI enrichment columns should be includedconfidenceEnabled- whether theai_confidencecolumn should be included; only meaningful whenaiEnabledistruecontentHashEnabled- whether thecontent_hashcolumn should be includeddriftDetect- whether thetag_ai_driftcolumn should be included; only meaningful whenaiEnabledistrueemitSourceRoot- whether asource_rootcolumn (CSV) orSRCROOT=token (plain) should be included; enable with-emit-source-rootwhen scanning a multi-root project where the same FQCN can appear under different source trees
-
-
Method Details
-
emitMetadata
Emits# key: valuemetadata comment lines before the CSV header.- Parameters:
version- tool version string, e.g.1.2.3ordevscanTimestamp- ISO-8601 timestamp of the scan starttaxonomyInfo- human-readable taxonomy descriptor
-
emitCsvHeader
Emits the CSV header line whenOutputMode.CSVis selected.Does nothing when plain-text mode is active.
- Parameters:
mode- selected output mode
-
emit
public void emit(OutputMode mode, String fqcn, String method, int loc, String contentHash, List<String> tags, String displayName, AiMethodSuggestion suggestion, String sourceRoot) Emits a single test method record in the configured output mode.- Parameters:
mode- selected output modefqcn- fully qualified class name containing the methodmethod- test method nameloc- inclusive line count of the method declarationcontentHash- SHA-256 fingerprint of the enclosing class source, ornullwhen-content-hashis not enabledtags- source-level tags extracted from the methoddisplayName- text from an existing display-name annotation on the method, or an empty string if absent;nullis treated as absentsuggestion- AI suggestion for the method, ornullif nonesourceRoot- CWD-relative path of the scan root, ornullwhen-emit-source-rootis not enabled
-
csvEscape
Escapes a value for inclusion in a CSV field.If the value contains a comma, double quote, carriage return, or line feed, it is wrapped in double quotes and embedded quotes are doubled. Values that start with
=,+,-, or@are also quoted to prevent spreadsheet formula injection. Anullinput is converted to an empty field.- Parameters:
value- value to escape; may benull- Returns:
- CSV-safe representation of
value
-