Class PmdXmlToJsonCommand
java.lang.Object
com.streamconverter.command.AbstractStreamCommand
com.streamconverter.command.impl.analysis.PmdXmlToJsonCommand
- All Implemented Interfaces:
IStreamCommand
PMD XML レポートを JSON 形式に変換するコマンド
StreamConverter アーキテクチャに準拠したJSON変換実装例です。 Jackson ObjectMapperを使用して型安全で構造化されたJSON出力を生成し、 プログラムによる解析やAPI連携に適したデータ形式を提供します。
出力JSON構造:
{ "summary": { "totalViolations": 2083, "generatedAt": "2025-08-19T16:45:00.123Z" }, "violations": [ { "file": "streamconverter-core/src/.../Example.java", "line": 42, "rule": "MethodArgumentCouldBeFinal", "category": "Code Style", "priority": 3, "description": "Parameter 'input' is not assigned...", "class": "Example", "method": "process", "variable": "input" } ] }
特徴:
- Jackson ObjectMapper による型安全なJSON生成
- ISO-8601 標準タイムスタンプ
- 構造化されたサマリー情報
- プリティプリント対応
使用例:
// StreamConverter パイプラインでの使用 StreamConverter converter = new StreamConverter( new PmdXmlToJsonCommand() ); converter.run(pmdXmlInputStream, jsonOutputStream);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
JSON レポートのルートオブジェクトstatic final record
JSON レポートのサマリー情報 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
executeInternal
(InputStream input, OutputStream output) PMD XML InputStream を JSON OutputStream に変換protected String
コマンドの詳細情報を取得します。Methods inherited from class com.streamconverter.command.AbstractStreamCommand
execute
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.streamconverter.command.IStreamCommand
execute
-
Constructor Details
-
PmdXmlToJsonCommand
public PmdXmlToJsonCommand()Creates a new command instance.Initializes the
ObjectMapper
with the following configuration:- Enables pretty-printing of JSON output (
SerializationFeature.INDENT_OUTPUT
). - Disables writing dates as timestamps, using ISO-8601 format instead (
SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
).
- Enables pretty-printing of JSON output (
-
-
Method Details
-
executeInternal
PMD XML InputStream を JSON OutputStream に変換- Specified by:
executeInternal
in classAbstractStreamCommand
- Parameters:
input
- PMD XML レポートの入力ストリームoutput
- JSON レポートの出力ストリーム- Throws:
IOException
- XML解析エラーまたはI/O例外の場合
-
getCommandDetails
Description copied from class:AbstractStreamCommand
コマンドの詳細情報を取得します。サブクラスでオーバーライドして、コマンド固有の設定や状態を返すことができます。 この情報はデバッグログに出力され、問題の診断に役立ちます。
- Overrides:
getCommandDetails
in classAbstractStreamCommand
- Returns:
- コマンドの詳細情報
-