001package com.streamconverter.command; 002 003import java.io.IOException; 004import java.io.InputStream; 005import java.io.OutputStream; 006import org.slf4j.Logger; 007import org.slf4j.LoggerFactory; 008 009/** 010 * Abstract class for stream commands. 011 * 012 * <p>This class provides a base for implementing {@link IStreamCommand} with a pre-configured 013 * logger. Subclasses implement {@link #execute(InputStream, OutputStream)} directly. 014 */ 015public abstract class AbstractStreamCommand implements IStreamCommand { 016 /** Logger instance for this command. Uses the actual subclass name for better traceability. */ 017 protected final Logger log; 018 019 /** 020 * Default constructor. 021 * 022 * <p>Initializes the command with default settings and creates a logger using the actual command 023 * class name. 024 */ 025 public AbstractStreamCommand() { 026 super(); 027 this.log = LoggerFactory.getLogger(getClass()); 028 } 029 030 /** 031 * Executes the command on the provided input stream and writes the result to the output stream. 032 * 033 * @param inputStream The input stream to read data from. 034 * @param outputStream The output stream to write data to. 035 * @throws IOException If an I/O error occurs during the execution of the command. 036 */ 037 @Override 038 public abstract void execute(InputStream inputStream, OutputStream outputStream) 039 throws IOException; 040}