001/*
002 * JRecordBind, fixed-length file (un)marshaller
003 * Copyright 2019, Federico Fissore, and individual contributors. See
004 * AUTHORS.txt in the distribution for a full listing of individual
005 * contributors.
006 *
007 * This is free software; you can redistribute it and/or modify it
008 * under the terms of the GNU Lesser General Public License as
009 * published by the Free Software Foundation; either version 2.1 of
010 * the License, or (at your option) any later version.
011 *
012 * This software is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this software; if not, write to the Free
019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021 */
022
023package org.fissore.jrecordbind;
024
025import java.io.Reader;
026
027/**
028 * When the {@link Unmarshaller} reads a text file, it reads it via a LineReader.<br>
029 * Unless specified, the default implementation will be used, {@link SimpleLineReader}, which will read each line and pass it to the {@link Unmarshaller}<br>
030 * Sometimes, text files contains lines you're not interested to, or you want to do some preprocessing before parsing them: in such cases, it's useful to provide your own implementation of LineReader
031 *
032 * @see SimpleLineReader
033 */
034public interface LineReader {
035
036  /**
037   * Reads a line from a Reader. This is where you want to add your customization
038   *
039   * @param reader            a reader, reading from a fixed-length file
040   * @param defaultPadder     the padder to optionally use when reading a line
041   * @param propertyDelimiter the delimiter used to delimit properties on a line
042   * @param recordLength      the total expected length of a line
043   * @param lineSeparator     the character sequence used to mark the end of a line
044   * @return a string, or null if there are no more lines to read
045   */
046  String readLine(Reader reader, Padder defaultPadder, String propertyDelimiter, int recordLength, String lineSeparator);
047
048}