001package org.unix4j.processor; 002 003import java.util.Collections; 004import java.util.List; 005 006import org.unix4j.io.Input; 007 008/** 009 * A line processor redirects a given {@link Input} stream to the standard input 010 * of a command. The command here is another {@link LineProcessor} reading the 011 * lines passed to it. If a command supports both (a) reading from the standard 012 * input and (b) input from a file, it implements a processor for (a) and reuses 013 * this processor for (b) nested in a {@code RedirectInputLineProcessor}. 014 * <p> 015 * The (standard) input is not read by this processor. See superclass 016 * {@link MultipleInputLineProcessor} for more information. 017 */ 018public class RedirectInputLineProcessor extends MultipleInputLineProcessor { 019 020 /** 021 * Constructor with input object (usually a file operand of the command) and 022 * the command processor that reads from the standard input. 023 * 024 * @param input 025 * the input device, usually a file operand of the command 026 * @param standardInputProcessor 027 * the processor performing the command operation based on lines 028 * from the standard input 029 */ 030 public RedirectInputLineProcessor(Input input, LineProcessor standardInputProcessor) { 031 this(Collections.singletonList(input), standardInputProcessor); 032 } 033 034 /** 035 * Constructor with multiple input objects (usually file operands of the 036 * command) and the command processor that reads from the standard input. 037 * The given input objects are processed in the given sequence; the 038 * {@code finish()} method of the {@code standardInputProcessor} is called 039 * after completing the last line of the last input. 040 * 041 * @param inputs 042 * the input devices, usually file operands of the command 043 * @param standardInputProcessor 044 * the processor performing the command operation based on lines 045 * from the standard input 046 */ 047 public RedirectInputLineProcessor(List<? extends Input> inputs, LineProcessor standardInputProcessor) { 048 super(inputs, new DefaultInputProcessor(), standardInputProcessor); 049 } 050 051}