Package com.streamconverter
Class StreamConverter
java.lang.Object
com.streamconverter.StreamConverter
ストリーム変換クラス。
ストリームを変換するクラス。ストリームを変換するコマンドを指定して、ストリームを変換する。
ストリームを変換するコマンドは、IStreamCommandインターフェースを実装したクラスである必要がある。
-
Constructor Summary
ConstructorsConstructorDescriptionStreamConverter
(IStreamCommand[] commands) Constructs a StreamConverter with the specified array of commands.StreamConverter
(List<IStreamCommand> commands) Constructs a StreamConverter with the specified list of commands. -
Method Summary
Modifier and TypeMethodDescriptionstatic StreamConverter
create
(IStreamCommand... commands) Creates a StreamConverter with the specified array of commands.static StreamConverter
create
(List<IStreamCommand> commands) Creates a StreamConverter with the specified list of commands.static StreamConverter
createWithContext
(ExecutionContext context, IStreamCommand... commands) Creates a StreamConverter with a custom ExecutionContext and specified commands.static StreamConverter
createWithContext
(ExecutionContext context, List<IStreamCommand> commands) Creates a StreamConverter with a custom ExecutionContext and specified commands list.run
(InputStream inputStream, OutputStream outputStream) 非同期並列処理でストリームを変換する。 メモリ効率を重視し、PipedStreamを使用して大容量ファイルに対応。 自動的にExecutionContextを生成してMDC同期を実現する。run
(InputStream inputStream, OutputStream outputStream, ExecutionContext context) カスタムExecutionContextを使用してストリームを変換する。 マルチスレッド環境でのMDCコンテキスト伝播とログトレーサビリティを実現。
-
Constructor Details
-
StreamConverter
Constructs a StreamConverter with the specified array of commands.- Parameters:
commands
- the array of commands to be executed in sequence- Throws:
NullPointerException
- if commands is nullIllegalArgumentException
- if commands is empty
-
StreamConverter
Constructs a StreamConverter with the specified list of commands.- Parameters:
commands
- the list of commands to be executed in sequence- Throws:
NullPointerException
- if commands is nullIllegalArgumentException
- if commands is empty
-
-
Method Details
-
create
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 nullIllegalArgumentException
- if commands is empty
-
create
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 nullIllegalArgumentException
- 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 loggingcommands
- the array of commands to be executed in sequence- Returns:
- a new StreamConverter instance
- Throws:
NullPointerException
- if context or commands is nullIllegalArgumentException
- if commands is empty
-
createWithContext
public static StreamConverter createWithContext(ExecutionContext context, List<IStreamCommand> commands) 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 loggingcommands
- the list of commands to be executed in sequence- Returns:
- a new StreamConverter instance
- Throws:
NullPointerException
- if context or commands is nullIllegalArgumentException
- 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エラーが発生した場合
-