OS400FTPEntryParserpublic class OS400FTPEntryParser extends ConfigurableFTPFileEntryParserImpl
Fields Summary |
---|
private static final String | DEFAULT_DATE_FORMAT | private static final String | REGEX |
Constructors Summary |
---|
public OS400FTPEntryParser()The default constructor for a OS400FTPEntryParser object. // filename
this(null);
| public OS400FTPEntryParser(org.apache.commons.net.ftp.FTPClientConfig config)This constructor allows the creation of an OS400FTPEntryParser object
with something other than the default configuration.
super(REGEX);
configure(config);
|
Methods Summary |
---|
protected 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_OS400,
DEFAULT_DATE_FORMAT,
null, null, null, null);
| public org.apache.commons.net.ftp.FTPFile | parseFTPEntry(java.lang.String entry)
FTPFile file = new FTPFile();
file.setRawListing(entry);
int type;
if (matches(entry))
{
String usr = group(1);
String filesize = group(2);
String datestr = group(3)+" "+group(4);
String typeStr = group(5);
String name = group(6);
try
{
file.setTimestamp(super.parseTimestamp(datestr));
}
catch (ParseException e)
{
return null; // this is a parsing failure too.
}
if (typeStr.equalsIgnoreCase("*STMF"))
{
type = FTPFile.FILE_TYPE;
}
else if (typeStr.equalsIgnoreCase("*DIR"))
{
type = FTPFile.DIRECTORY_TYPE;
}
else
{
type = FTPFile.UNKNOWN_TYPE;
}
file.setType(type);
file.setUser(usr);
try
{
file.setSize(Long.parseLong(filesize));
}
catch (NumberFormatException e)
{
// intentionally do nothing
}
if (name.endsWith("/"))
{
name = name.substring(0, name.length() - 1);
}
int pos = name.lastIndexOf('/");
if (pos > -1)
{
name = name.substring(pos + 1);
}
file.setName(name);
return file;
}
return null;
|
|