001/* 002 * Copyright (C) 2009 The Guava Authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.google.common.io; 018 019import com.google.common.annotations.Beta; 020 021import java.io.IOException; 022 023/** 024 * A callback to be used with the streaming {@code readLines} methods. 025 * 026 * <p>{@link #processLine} will be called for each line that is read, and 027 * should return {@code false} when you want to stop processing. 028 * 029 * @author Miles Barr 030 * @since 1.0 031 */ 032@Beta 033public interface LineProcessor<T> { 034 035 /** 036 * This method will be called once for each line. 037 * 038 * @param line the line read from the input, without delimiter 039 * @return true to continue processing, false to stop 040 */ 041 boolean processLine(String line) throws IOException; 042 043 /** Return the result of processing all the lines. */ 044 T getResult(); 045}