Class StreamConverter

java.lang.Object
com.streamconverter.StreamConverter

public class StreamConverter extends Object
ストリーム変換クラス。

ストリームを変換するクラス。ストリームを変換するコマンドを指定して、ストリームを変換する。

ストリームを変換するコマンドは、IStreamCommandインターフェースを実装したクラスである必要がある。

  • Constructor Details

  • Method Details

    • create

      public static StreamConverter create(IStreamCommand... commands)
      Creates a StreamConverter with the specified array of commands.
      Parameters:
      commands - the array of commands to be executed in sequence
      Returns:
      a new StreamConverter instance
      Throws:
      NullPointerException - if commands is null
      IllegalArgumentException - if commands is empty
    • create

      public static StreamConverter create(List<IStreamCommand> commands)
      Creates a StreamConverter with the specified list of commands.
      Parameters:
      commands - the list of commands to be executed in sequence
      Returns:
      a new StreamConverter instance
      Throws:
      NullPointerException - if commands is null
      IllegalArgumentException - if commands is empty
    • createWithContext

      public static StreamConverter createWithContext(ExecutionContext context, IStreamCommand... commands)
      Creates a StreamConverter with a custom ExecutionContext and specified commands. All subsequent runs will use the provided context for MDC synchronization.
      Parameters:
      context - the execution context to use for MDC and logging
      commands - the array of commands to be executed in sequence
      Returns:
      a new StreamConverter instance
      Throws:
      NullPointerException - if context or commands is null
      IllegalArgumentException - if commands is empty
    • createWithContext

      Creates a StreamConverter with a custom ExecutionContext and specified commands list. All subsequent runs will use the provided context for MDC synchronization.
      Parameters:
      context - the execution context to use for MDC and logging
      commands - the list of commands to be executed in sequence
      Returns:
      a new StreamConverter instance
      Throws:
      NullPointerException - if context or commands is null
      IllegalArgumentException - if commands is empty
    • run

      public List<CommandResult> run(InputStream inputStream, OutputStream outputStream) throws IOException
      非同期並列処理でストリームを変換する。 メモリ効率を重視し、PipedStreamを使用して大容量ファイルに対応。 自動的にExecutionContextを生成してMDC同期を実現する。
      Parameters:
      inputStream - 処理対象の入力ストリーム
      outputStream - 処理結果を書き込む出力ストリーム
      Returns:
      各コマンドの実行結果リスト
      Throws:
      IOException - ストリーム処理中にI/Oエラーが発生した場合
    • run

      public List<CommandResult> run(InputStream inputStream, OutputStream outputStream, ExecutionContext context) throws IOException
      カスタムExecutionContextを使用してストリームを変換する。 マルチスレッド環境でのMDCコンテキスト伝播とログトレーサビリティを実現。
      Parameters:
      inputStream - 処理対象の入力ストリーム
      outputStream - 処理結果を書き込む出力ストリーム
      context - 実行コンテキスト
      Returns:
      各コマンドの実行結果リスト
      Throws:
      IOException - ストリーム処理中にI/Oエラーが発生した場合