    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017
    018package org.apache.commons.net.ftp;
    019
    020import java.io.BufferedReader;
    021import java.io.IOException;
    022import java.util.List;
    023
    024/**
    025 * This abstract class implements both the older FTPFileListParser and newer FTPFileEntryParser interfaces with default functionality. All the classes in the
    026 * parser subpackage inherit from this.
    027 *
    028 */
    029public abstract class FTPFileEntryParserImpl implements FTPFileEntryParser {
    030    /**
    031     * The constructor for a FTPFileEntryParserImpl object.
    032     */
    033    public FTPFileEntryParserImpl() {
    034    }
    035
    036    /**
    037     * This method is a hook for those implementors (such as VMSVersioningFTPEntryParser, and possibly others) which need to perform some action upon the
    038     * FTPFileList after it has been created from the server stream, but before any clients see the list.
    039     *
    040     * This default implementation does nothing.
    041     *
    042     * @param original Original list after it has been created from the server stream
    043     *
    044     * @return <code>original</code> unmodified.
    045     */
    046    @Override
    047    public List<String> preParse(final List<String> original) {
    048        return original;
    049    }
    050
    051    /**
    052     * Reads the next entry using the supplied BufferedReader object up to whatever delimits one entry from the next. This default implementation simply calls
    053     * BufferedReader.readLine().
    054     *
    055     * @param reader The BufferedReader object from which entries are to be read.
    056     *
    057     * @return A string representing the next ftp entry or null if none found.
    058     * @throws IOException thrown on any IO Error reading from the reader.
    059     */
    060    @Override
    061    public String readNextEntry(final BufferedReader reader) throws IOException {
    062        return reader.readLine();
    063    }
    064}