public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
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.
| Modifier and Type | Field and Description |
|---|---|
(package private) static String |
DEFAULT_DATE_FORMAT |
(package private) static String |
DEFAULT_RECENT_DATE_FORMAT |
static 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. |
(package private) static String |
NUMERIC_DATE_FORMAT |
(package private) boolean |
trimLeadingSpaces
Whether leading spaces are trimmed from file names this was the case for the original implementation.
|
_matcher_| Constructor and Description |
|---|
UnixFTPEntryParser()
Constructs a new instance.
|
UnixFTPEntryParser(FTPClientConfig config)
Constructs a new instance with something other than the default configuration.
|
UnixFTPEntryParser(FTPClientConfig config,
boolean trimLeadingSpaces)
Constructs a new instance with something other than the default configuration.
|
| Modifier and Type | Method and Description |
|---|---|
protected FTPClientConfig |
getDefaultConfiguration()
Gets a new default configuration to be used when this class is instantiated without a
FTPClientConfig parameter being specified. |
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. |
List<String> |
preParse(List<String> original)
Preparses the list to discard "total nnn" lines.
|
configure, parseTimestampgetGroupCnt, getGroupsAsString, group, matches, setRegex, setRegexreadNextEntrystatic final String DEFAULT_DATE_FORMAT
static final String DEFAULT_RECENT_DATE_FORMAT
public static final FTPClientConfig NUMERIC_DATE_CONFIG
"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
static final String NUMERIC_DATE_FORMAT
final boolean trimLeadingSpaces
public UnixFTPEntryParser()
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.public UnixFTPEntryParser(FTPClientConfig config)
config - The configuration object used to configure this parser.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.public UnixFTPEntryParser(FTPClientConfig config, boolean trimLeadingSpaces)
config - The configuration object used to configure this parser.trimLeadingSpaces - if true, trim leading spaces from file namesIllegalArgumentException - 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.protected FTPClientConfig getDefaultConfiguration()
FTPClientConfig parameter being specified.getDefaultConfiguration in class ConfigurableFTPFileEntryParserImplpublic FTPFile parseFTPEntry(String entry)
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.entry - A line of text from the file listingpublic List<String> preParse(List<String> original)
preParse in interface FTPFileEntryParserpreParse in class FTPFileEntryParserImploriginal - Original list after it has been created from the server streamoriginal unmodified.