Class StreamConverter

java.lang.Object
com.streamconverter.StreamConverter

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

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

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

親スレッドのMDCコンテキストは、InheritableMDCAdapterが インストールされている場合、各コマンドの仮想スレッドに自動的に伝搬される。MDCInitializer.initialize()が呼ばれていない場合、各ワーカースレッドは 独立した空のMDCコンテキストを持ち、親スレッドのMDC値は伝搬されない。

  • 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
    • run

      public void run(InputStream inputStream, OutputStream outputStream) throws IOException
      非同期並列処理でストリームを変換する。 メモリ効率を重視し、PipedStreamを使用して大容量ファイルに対応。
      Parameters:
      inputStream - 処理対象の入力ストリーム
      outputStream - 処理結果を書き込む出力ストリーム
      Throws:
      IOException - ストリーム処理中にI/Oエラーが発生した場合