VMSFTPEntryParserpublic class VMSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl Implementation FTPFileEntryParser and FTPFileListParser for VMS Systems.
This is a sample of VMS LIST output
"1-JUN.LIS;1 9/9 2-JUN-1998 07:32:04 [GROUP,OWNER] (RWED,RWED,RWED,RE)",
"1-JUN.LIS;2 9/9 2-JUN-1998 07:32:04 [GROUP,OWNER] (RWED,RWED,RWED,RE)",
"DATA.DIR;1 1/9 2-JUN-1998 07:32:04 [GROUP,OWNER] (RWED,RWED,RWED,RE)",
Note: VMSFTPEntryParser can only be instantiated through the
DefaultFTPParserFactory by classname. It will not be chosen
by the autodetection scheme.
|
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 VMSFTPEntryParser()Constructor for a VMSFTPEntryParser object.
this(null);
| public VMSFTPEntryParser(org.apache.commons.net.ftp.FTPClientConfig config)This constructor allows the creation of a VMSFTPEntryParser 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_VMS,
DEFAULT_DATE_FORMAT,
null, null, null, null);
| protected boolean | isVersioning()
return false;
| public org.apache.commons.net.ftp.FTPFile | parseFTPEntry(java.lang.String entry)Parses a line of a VMS 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.
//one block in VMS equals 512 bytes
long longBlock = 512;
if (matches(entry))
{
FTPFile f = new FTPFile();
f.setRawListing(entry);
String name = group(1);
String size = group(2);
String datestr = group(3)+" "+group(4);
String owner = group(5);
try
{
f.setTimestamp(super.parseTimestamp(datestr));
}
catch (ParseException e)
{
return null; // this is a parsing failure too.
}
String grp;
String user;
StringTokenizer t = new StringTokenizer(owner, ",");
switch (t.countTokens()) {
case 1:
grp = null;
user = t.nextToken();
break;
case 2:
grp = t.nextToken();
user = t.nextToken();
break;
default:
grp = null;
user = null;
}
if (name.lastIndexOf(".DIR") != -1)
{
f.setType(FTPFile.DIRECTORY_TYPE);
}
else
{
f.setType(FTPFile.FILE_TYPE);
}
//set FTPFile name
//Check also for versions to be returned or not
if (isVersioning())
{
f.setName(name);
}
else
{
name = name.substring(0, name.lastIndexOf(";"));
f.setName(name);
}
//size is retreived in blocks and needs to be put in bytes
//for us humans and added to the FTPFile array
long sizeInBytes = Long.parseLong(size) * longBlock;
f.setSize(sizeInBytes);
f.setGroup(grp);
f.setUser(user);
//set group and owner
//Since I don't need the persmissions on this file (RWED), I'll
//leave that for further development. 'Cause it will be a bit
//elaborate to do it right with VMSes World, Global and so forth.
return f;
}
return null;
| public org.apache.commons.net.ftp.FTPFile[] | parseFileList(java.io.InputStream listStream)Parses an FTP server file listing and converts it into a usable format
in the form of an array of FTPFile instances. If the
file list contains no files, null should be
returned, otherwise an array of FTPFile instances
representing the files in the directory is returned.
FTPListParseEngine engine = new FTPListParseEngine(this);
engine.readServerList(listStream);
return engine.getFiles();
| public java.lang.String | readNextEntry(java.io.BufferedReader reader)Reads the next entry using the supplied BufferedReader object up to
whatever delemits one entry from the next. This parser cannot use
the default implementation of simply calling BufferedReader.readLine(),
because one entry may span multiple lines.
String line = reader.readLine();
StringBuffer entry = new StringBuffer();
while (line != null)
{
if (line.startsWith("Directory") || line.startsWith("Total")) {
line = reader.readLine();
continue;
}
entry.append(line);
if (line.trim().endsWith(")"))
{
break;
}
line = reader.readLine();
}
return (entry.length() == 0 ? null : entry.toString());
|
|