Package org.apache.commons.net.ftp

# Interface FTPFileEntryParser

All Known Implementing Classes:
  `CompositeFileEntryParser`, `ConfigurableFTPFileEntryParserImpl`, `EnterpriseUnixFTPEntryParser`, `FTPFileEntryParserImpl`, `MacOsPeterFTPEntryParser`, `MLSxEntryParser`, `MVSFTPEntryParser`, `NetwareFTPEntryParser`, `NTFTPEntryParser`, `OS2FTPEntryParser`, `OS400FTPEntryParser`, `RegexFTPFileEntryParserImpl`, `UnixFTPEntryParser`, `VMSFTPEntryParser`, `VMSVersioningFTPEntryParser`

public interface FTPFileEntryParser
FTPFileEntryParser defines the interface for parsing a single FTP file listing and converting that information into an `FTPFile` instance. Sometimes you will want to parse unusual listing formats, in which case you would create your own implementation of FTPFileEntryParser and if necessary, subclass FTPFile.

Here are some examples showing how to use one of the classes that implement this interface.

The first example uses the `FTPClient.listFiles()` API to pull the whole list from the subfolder `subfolder` in one call, attempting to automatically detect the parser type. This method, without a parserKey parameter, indicates that autodection should be used.

     FTPClient f = FTPClient();
     f.connect(server);
     f.login(user, password);
     FTPFile[] files = f.listFiles("subfolder");

The second example uses the `FTPClient.listFiles()` API to pull the whole list from the current working directory in one call, but specifying by class name the parser to be used. For this particular parser class, this approach is necessary since there is no way to autodetect this server type.

     FTPClient f = FTPClient();
     f.connect(server);
     f.login(user, password);
     FTPFile[] files = f.listFiles("org.apache.commons.net.ftp.parser.EnterpriseUnixFTPFileEntryParser", ".");

The third example uses the `FTPClient.listFiles()` API to pull a single file listing in an arbitrary directory in one call, specifying by KEY the parser to be used, in this case, VMS.

     FTPClient f = FTPClient();
     f.connect(server);
     f.login(user, password);
     FTPFile[] files = f.listFiles("VMS", "subfolder/foo.java");

For an alternative approach, see the `FTPListParseEngine` class which provides iterative access.

See Also:
  - `FTPFile`
  - `FTPClient.listFiles()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `FTPFile`
  `parseFTPEntry(String listEntry)`
  Parses a line of an FTP server file listing and converts it into a usable format in the form of an `FTPFile` instance.
  `List<String>`
  `preParse(List<String> original)`
  This method is a hook for those implementors (such as VMSVersioningFTPEntryParser, and possibly others) which need to perform some action upon the FTPFileList after it has been created from the server stream, but before any clients see the list.
  `String`
  `readNextEntry(BufferedReader reader)`
  Reads the next entry using the supplied BufferedReader object up to whatever delimits one entry from the next.

- ## Method Details

  - ### parseFTPEntry

    FTPFile parseFTPEntry(String listEntry)
    Parses a line of an FTP server file listing and converts it into a usable format in the form of an `FTPFile` instance. If the file listing line doesn't describe a file, `null` should be returned, otherwise a `FTPFile` instance representing the files in the directory is returned.
    Parameters:
      `listEntry` - A line of text from the file listing
    Returns:
      An FTPFile instance corresponding to the supplied entry

  - ### preParse

    List<String> preParse(List<String> original)
    This method is a hook for those implementors (such as VMSVersioningFTPEntryParser, and possibly others) which need to perform some action upon the FTPFileList after it has been created from the server stream, but before any clients see the list. The default implementation can be a no-op.
    Parameters:
      `original` - Original list after it has been created from the server stream
    Returns:
      Original list as processed by this method.

  - ### readNextEntry

    String readNextEntry(BufferedReader reader) throws IOException
    Reads the next entry using the supplied BufferedReader object up to whatever delimits one entry from the next. Implementors must define this for the particular ftp system being parsed. In many but not all cases, this can be defined simply by calling BufferedReader.readLine().
    Parameters:
      `reader` - The BufferedReader object from which entries are to be read.
    Returns:
      A string representing the next ftp entry or null if none found.
    Throws:
      `IOException` - thrown on any IO Error reading from the reader.