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

CompositeFileEntryParser

public class CompositeFileEntryParser extends org.apache.commons.net.ftp.FTPFileEntryParserImpl
This implementation allows to pack some FileEntryParsers together and handle the case where to returned dirstyle isnt clearly defined. The matching parser will be cached. If the cached parser wont match due to the server changed the dirstyle, a new matching parser will be searched.
author
Mario Ivankovits

Fields Summary
private final org.apache.commons.net.ftp.FTPFileEntryParser[]
ftpFileEntryParsers
private org.apache.commons.net.ftp.FTPFileEntryParser
cachedFtpFileEntryParser
Constructors Summary
public CompositeFileEntryParser(org.apache.commons.net.ftp.FTPFileEntryParser[] ftpFileEntryParsers)

        super();

        this.cachedFtpFileEntryParser = null;
        this.ftpFileEntryParsers = ftpFileEntryParsers;
    
Methods Summary
public org.apache.commons.net.ftp.FTPFileparseFTPEntry(java.lang.String listEntry)

        if (cachedFtpFileEntryParser != null)
        {
            FTPFile matched = cachedFtpFileEntryParser.parseFTPEntry(listEntry);
            if (matched != null)
            {
                return matched;
            }
        }
        else
        {
            for (int iterParser=0; iterParser < ftpFileEntryParsers.length; iterParser++)
            {
                FTPFileEntryParser ftpFileEntryParser = ftpFileEntryParsers[iterParser];

                FTPFile matched = ftpFileEntryParser.parseFTPEntry(listEntry);
                if (matched != null)
                {
                    cachedFtpFileEntryParser = ftpFileEntryParser;
                    return matched;
                }
            }
        }
        return null;