NTFTPEntryParserpublic class NTFTPEntryParser extends ConfigurableFTPFileEntryParserImpl Implementation of FTPFileEntryParser and FTPFileListParser for NT Systems. |
Fields Summary |
---|
private static final String | DEFAULT_DATE_FORMAT | private static final String | REGEXthis is the regular expression used by this parser. |
Constructors Summary |
---|
public NTFTPEntryParser()The sole constructor for an NTFTPEntryParser object.
this(null);
| public NTFTPEntryParser(org.apache.commons.net.ftp.FTPClientConfig config)This constructor allows the creation of an NTFTPEntryParser object
with something other than the default configuration.
super(REGEX);
configure(config);
|
Methods Summary |
---|
public org.apache.commons.net.ftp.FTPClientConfig | getDefaultConfiguration()Defines a default configuration to be used when this class is
instantiated without a {@link FTPClientConfig FTPClientConfig}
parameter being specified.
return new FTPClientConfig(
FTPClientConfig.SYST_NT,
DEFAULT_DATE_FORMAT,
null, null, null, null);
| public org.apache.commons.net.ftp.FTPFile | parseFTPEntry(java.lang.String entry)Parses a line of an NT 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.
FTPFile f = new FTPFile();
f.setRawListing(entry);
if (matches(entry))
{
String datestr = group(1)+" "+group(2);
String dirString = group(3);
String size = group(4);
String name = group(5);
try
{
f.setTimestamp(super.parseTimestamp(datestr));
}
catch (ParseException e)
{
return null; // this is a parsing failure too.
}
if (null == name || name.equals(".") || name.equals(".."))
{
return (null);
}
f.setName(name);
if ("<DIR>".equals(dirString))
{
f.setType(FTPFile.DIRECTORY_TYPE);
f.setSize(0);
}
else
{
f.setType(FTPFile.FILE_TYPE);
if (null != size)
{
f.setSize(Long.parseLong(size));
}
}
return (f);
}
return null;
|
|