Class LoggingDecorator

java.lang.Object
com.streamconverter.command.LoggingDecorator
All Implemented Interfaces:
IStreamCommand

public class LoggingDecorator extends Object implements IStreamCommand
IStreamCommandのログ出力デコレーター

このクラスは既存のIStreamCommandをラップして、詳細なログ出力機能を追加します。 デコレーターパターンを使用することで、既存のコマンドを変更せずに 追加のログ機能を提供できます。

使用例:

 IStreamCommand originalCommand = new CsvNavigateCommand("name");
 IStreamCommand loggedCommand = new LoggingDecorator(originalCommand);
 loggedCommand.execute(inputStream, outputStream);
 
  • Constructor Details

    • LoggingDecorator

      public LoggingDecorator(IStreamCommand delegate)
      コンストラクタ
      Parameters:
      delegate - ラップ対象のコマンド
    • LoggingDecorator

      public LoggingDecorator(IStreamCommand delegate, String loggerName)
      カスタムログ名を指定するコンストラクタ
      Parameters:
      delegate - ラップ対象のコマンド
      loggerName - ログ名
  • Method Details

    • execute

      public void execute(InputStream inputStream, OutputStream outputStream) throws IOException
      Description copied from interface: IStreamCommand
      Executes the command on the provided input stream and writes the result to the output stream.

      This method maintains backward compatibility for existing implementations. When called without ExecutionContext, a new context will be automatically created by the StreamConverter pipeline.

      Specified by:
      execute in interface IStreamCommand
      Parameters:
      inputStream - The input stream to read data from.
      outputStream - The output stream to write data to.
      Throws:
      IOException - If an I/O error occurs during the execution of the command.
    • getDelegate

      ラップされているコマンドを取得
      Returns:
      ラップされているコマンド
    • getCommandName

      コマンド名を取得
      Returns:
      コマンド名