001package org.unix4j.unix.grep;
002
003import org.unix4j.context.ExecutionContext;
004import org.unix4j.line.Line;
005import org.unix4j.processor.LineProcessor;
006
007/**
008 * Writes all matching lines to the output. The matching operation is delegated
009 * to the {@link LineMatcher} passed to the constructor. 
010 */
011final class WriteMatchingLinesProcessor extends AbstractGrepProcessor {
012        
013        public WriteMatchingLinesProcessor(GrepCommand command, ExecutionContext context, LineProcessor output, LineMatcher matcher) {
014                super(command, context, output, matcher);
015        }
016
017        @Override
018        protected boolean processLine(Line line, boolean isMatch) {
019                if (isMatch) {
020                        return getOutput().processLine(line);
021                }
022                return true;//this line is not a match, but we still want the next line
023        }
024}