Class UnixFTPEntryParser

All Implemented Interfaces:
Configurable, FTPFileEntryParser

public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
Implementation FTPFileEntryParser and FTPFileListParser for standard UNIX Systems. This class is based on the logic of Daniel Savarese's DefaultFTPListParser, but adapted to use regular expressions and to fit the new FTPFileEntryParser interface.
See Also:
  • Field Details

    • DEFAULT_DATE_FORMAT

      static final String DEFAULT_DATE_FORMAT
      See Also:
    • DEFAULT_RECENT_DATE_FORMAT

      static final String DEFAULT_RECENT_DATE_FORMAT
      See Also:
    • NUMERIC_DATE_FORMAT

      static final String NUMERIC_DATE_FORMAT
      See Also:
    • JA_MONTH

      private static final String JA_MONTH
      See Also:
    • JA_DAY

      private static final String JA_DAY
      See Also:
    • JA_YEAR

      private static final String JA_YEAR
      See Also:
    • DEFAULT_DATE_FORMAT_JA

      private static final String DEFAULT_DATE_FORMAT_JA
      See Also:
    • DEFAULT_RECENT_DATE_FORMAT_JA

      private static final String DEFAULT_RECENT_DATE_FORMAT_JA
      See Also:
    • TOTAL_PATTERN

      private static final Pattern TOTAL_PATTERN
    • NUMERIC_DATE_CONFIG

      public static final FTPClientConfig NUMERIC_DATE_CONFIG
      Some Linux distributions are now shipping an FTP server which formats file listing dates in an all-numeric format: "yyyy-MM-dd HH:mm. This is a very welcome development, and hopefully it will soon become the standard. However, since it is so new, for now, and possibly forever, we merely accommodate it, but do not make it the default.

      For now end users may specify this format only via UnixFTPEntryParser(FTPClientConfig). Steve Cohen - 2005-04-17

    • REGEX

      private static final String REGEX
      this is the regular expression used by this parser. Permissions: r the file is readable w the file is writable x the file is executable - the indicated permission is not granted L mandatory locking occurs during access (the set-group-ID bit is on and the group execution bit is off) s the set-user-ID or set-group-ID bit is on, and the corresponding user or group execution bit is also on S undefined bit-state (the set-user-ID bit is on and the user execution bit is off) t the 1000 (octal) bit, or sticky bit, is on [see chmod(1)], and execution is on T the 1000 bit is turned on, and execution is off (undefined bit-state) e z/OS external link bit. Final letter may be appended: + file has extended security attributes (e.g. ACL) Note: local listings on MacOSX also use '@'; this is not allowed for here as does not appear to be shown by FTP servers @ file has extended attributes
      See Also:
    • trimLeadingSpaces

      final boolean trimLeadingSpaces
  • Constructor Details

    • UnixFTPEntryParser

      public UnixFTPEntryParser()
      The default constructor for a UnixFTPEntryParser object.
      Throws:
      IllegalArgumentException - Thrown if the regular expression is unparseable. Should not be seen under normal conditions. If this exception is seen, this is a sign that REGEX is not a valid regular expression.
    • UnixFTPEntryParser

      public UnixFTPEntryParser(FTPClientConfig config)
      This constructor allows the creation of a UnixFTPEntryParser object with something other than the default configuration.
      Parameters:
      config - The configuration object used to configure this parser.
      Throws:
      IllegalArgumentException - Thrown if the regular expression is unparseable. Should not be seen under normal conditions. If this exception is seen, this is a sign that REGEX is not a valid regular expression.
      Since:
      1.4
    • UnixFTPEntryParser

      public UnixFTPEntryParser(FTPClientConfig config, boolean trimLeadingSpaces)
      This constructor allows the creation of a UnixFTPEntryParser object with something other than the default configuration.
      Parameters:
      config - The configuration object used to configure this parser.
      trimLeadingSpaces - if true, trim leading spaces from file names
      Throws:
      IllegalArgumentException - Thrown if the regular expression is unparseable. Should not be seen under normal conditions. If this exception is seen, this is a sign that REGEX is not a valid regular expression.
      Since:
      3.4
  • Method Details

    • getDefaultConfiguration

      protected FTPClientConfig getDefaultConfiguration()
      Defines a default configuration to be used when this class is instantiated without a FTPClientConfig parameter being specified.
      Specified by:
      getDefaultConfiguration in class ConfigurableFTPFileEntryParserImpl
      Returns:
      the default configuration for this parser.
    • parseFTPEntry

      public FTPFile parseFTPEntry(String entry)
      Parses a line of a unix (standard) 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 is returned, otherwise a FTPFile instance representing the files in the directory is returned.
      Parameters:
      entry - A line of text from the file listing
      Returns:
      An FTPFile instance corresponding to the supplied entry
    • preParse

      public List<String> preParse(List<String> original)
      Preparses the list to discard "total nnn" lines.
      Specified by:
      preParse in interface FTPFileEntryParser
      Overrides:
      preParse in class FTPFileEntryParserImpl
      Parameters:
      original - Original list after it has been created from the server stream
      Returns:
      original unmodified.