FileDocCategorySizeDatePackage
OS400FTPEntryParser.javaAPI DocApache Commons NET 1.4.1 API4509Sat Dec 03 10:05:48 GMT 2005org.apache.commons.net.ftp.parser

OS400FTPEntryParser

public class OS400FTPEntryParser extends ConfigurableFTPFileEntryParserImpl
version
$Id: OS400FTPEntryParser.java 155429 2005-02-26 13:13:04Z dirkv $

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.

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

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

param
config The {@link FTPClientConfig configuration} object used to configure this parser.
exception
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.
since
1.4

        super(REGEX);
        configure(config);
    
Methods Summary
protected org.apache.commons.net.ftp.FTPClientConfiggetDefaultConfiguration()
Defines a default configuration to be used when this class is instantiated without a {@link FTPClientConfig FTPClientConfig} parameter being specified.

return
the default configuration for this parser.

        return new FTPClientConfig(
                FTPClientConfig.SYST_OS400,
                DEFAULT_DATE_FORMAT,
                null, null, null, null);
    
public org.apache.commons.net.ftp.FTPFileparseFTPEntry(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;