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);
 
  • Constructor Details

    • 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).
      This configuration affects the formatting and date representation in the generated JSON reports.
  • Method Details