org.apache.commons.net.ftp.parser
Class VMSFTPEntryParser

java.lang.Object
  |
  +--org.apache.commons.net.ftp.FTPFileListParserImpl
        |
        +--org.apache.commons.net.ftp.parser.VMSFTPEntryParser
All Implemented Interfaces:
FTPFileEntryParser, FTPFileListParser

public class VMSFTPEntryParser
extends FTPFileListParserImpl

This Class uses the FTPEntryParser class to validate the input string. It also requires the Commons/Net library version 1.0.0 or later and the Jakarta/ORO library for the regualar expressions stuff.

USAGE:

  • Create an instance of VMSFTPEntryParser
  • VMSFTPEntryParser parser = new VMSFTPEntryParser(boolean);
    True = returns all versions of a file with the respective ;#
    False = only the last version will return (Default)
  • Create an instance of FTPClient
  • FTPClient FTPClientObj = new FTPClient();
  • Connect to the NODE
  • FTPClientObj.connect();
  • Login to the NODE
  • FTPClientObj.login(username,password);
  • Switch directories if you have to
  • FTPClientObj.changeWorkingDirectory(thePath);
  • You might want to check if you are truly in a VMS System
  • And how do I do that you ask? easy... VMS is such a wonderful OS that when we do
    String am_I_VMS = FTPClientObj.getSystemName()
    it returns NULL, while everyone else returns the FTP servername
  • Call listFiles passing the newly created parser and a filename or a mask to look for
  • FTPClientObj.listFiles(parser,filename);
  • You'll get back the list as an array of FTPFile objects like this
    FTPFile[] myVMSFiles = FTPClientObj.listFiles(parser,filename); (or)
    FTPFile[] myVMSFiles = FTPClientObj.listFiles(parser);
    If filename is a filename and versioning is OFF, the version
    you requested will come back without the ;#

    That's all there is to it.

    Each FTPFile object is populated just like any other FTPFile object. The only thing not implemented at this time is the file permissions, but I can do it if there is a real need for it.

    !NOTE/WARNING!:Before you pass the parser to listFiles, make sure you are in the directory that you need to be. This parser will return the filtered files from the directory it is in. This becomes crucial specialy if your goal is to delete the output of the parser.

    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)",

    Version:
    $Id: VMSFTPEntryParser.java,v 1.7 2003/08/05 18:10:38 dfs Exp $
    Author:
    Winston Ojeda, Steve Cohen, Stephane ESTE-GRACIAS

    Field Summary
    private static java.lang.String MONTHS
              months abbreviations looked for by this parser.
    private static org.apache.oro.text.regex.Pattern OWNER_SPLIT_PATTERN
              Pattern for splitting owner listing.
    private static java.lang.String REGEX
              this is the regular expression used by this parser.
    private  boolean versioning
              settable option of whether or not to include versioning information with the file list.
     
    Fields inherited from class org.apache.commons.net.ftp.FTPFileListParserImpl
    _matcher_
     
    Constructor Summary
    VMSFTPEntryParser()
              Convenience Constructor for a VMSFTPEntryParser object.
    VMSFTPEntryParser(boolean versioning)
              Constructor for a VMSFTPEntryParser object.
     
    Method Summary
     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.
     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.
     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.
     
    Methods inherited from class org.apache.commons.net.ftp.FTPFileListParserImpl
    getGroupCnt, getGroupsAsString, group, matches
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    versioning

    private boolean versioning
    settable option of whether or not to include versioning information with the file list.


    MONTHS

    private static final java.lang.String MONTHS
    months abbreviations looked for by this parser. Also used to determine which month has been matched by the parser.

    See Also:
    Constant Field Values

    REGEX

    private static final java.lang.String REGEX
    this is the regular expression used by this parser.

    See Also:
    Constant Field Values

    OWNER_SPLIT_PATTERN

    private static final org.apache.oro.text.regex.Pattern OWNER_SPLIT_PATTERN
    Pattern for splitting owner listing.

    Constructor Detail

    VMSFTPEntryParser

    public VMSFTPEntryParser()
    Convenience Constructor for a VMSFTPEntryParser object. Sets the versioning member false

    Throws:
    java.lang.IllegalArgumentException - Thrown if the regular expression is unparseable. Should not be seen under normal conditions. It it is seen, this is a sign that REGEX is not a valid regular expression.

    VMSFTPEntryParser

    public VMSFTPEntryParser(boolean versioning)
    Constructor for a VMSFTPEntryParser object. Sets the versioning member to the supplied value.

    Parameters:
    versioning - Value to which versioning is to be set.
    Throws:
    java.lang.IllegalArgumentException - Thrown if the regular expression is unparseable. Should not be seen under normal conditions. It it is seen, this is a sign that REGEX is not a valid regular expression.
    Method Detail

    parseFileList

    public FTPFile[] parseFileList(java.io.InputStream listStream)
                            throws java.io.IOException
    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.

    Specified by:
    parseFileList in interface FTPFileListParser
    Overrides:
    parseFileList in class FTPFileListParserImpl
    Parameters:
    listStream - The InputStream from which the file list should be read.
    Returns:
    The list of file information contained in the given path. null if the list could not be obtained or if there are no files in the directory.
    Throws:
    java.io.IOException - If an I/O error occurs reading the listStream.

    parseFTPEntry

    public 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.

    Parameters:
    entry - A line of text from the file listing
    Returns:
    An FTPFile instance corresponding to the supplied entry

    readNextEntry

    public java.lang.String readNextEntry(java.io.BufferedReader reader)
                                   throws java.io.IOException
    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.

    Specified by:
    readNextEntry in interface FTPFileEntryParser
    Overrides:
    readNextEntry in class FTPFileListParserImpl
    Parameters:
    reader - The BufferedReader object from which entries are to be read.
    Returns:
    A string representing the next ftp entry or null if none found.
    Throws:
    java.io.IOException - thrown on any IO Error reading from the reader.