Class DefaultFTPFileEntryParserFactory
- java.lang.Object
-
- org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory
-
- All Implemented Interfaces:
FTPFileEntryParserFactory
public class DefaultFTPFileEntryParserFactory extends java.lang.Object implements FTPFileEntryParserFactory
This is the default implementation of the FTPFileEntryParserFactory interface. This is the implementation that will be used by org.apache.commons.net.ftp.FTPClient.listFiles() if no other implementation has been specified.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringJAVA_IDENTIFIERMatch a plain Java Identifierprivate static java.lang.StringJAVA_QUALIFIED_NAMEMatch a qualified name, e.g.private static java.util.regex.PatternJAVA_QUALIFIED_NAME_PATTERNCreate the pattern, as it will be reused many times
-
Constructor Summary
Constructors Constructor Description DefaultFTPFileEntryParserFactory()Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FTPFileEntryParsercreateFileEntryParser(java.lang.String key)This default implementation of the FTPFileEntryParserFactory interface works according to the following logic: First it attempts to interpret the supplied key as a fully qualified class name (default package is not allowed) of a class implementing the FTPFileEntryParser interface.private FTPFileEntryParsercreateFileEntryParser(java.lang.String key, FTPClientConfig config)FTPFileEntryParsercreateFileEntryParser(FTPClientConfig config)Implementation extracts a key from the suppliedFTPClientConfigparameter and creates an object implementing the interface FTPFileEntryParser and uses the supplied configuration to configure it.FTPFileEntryParsercreateMVSEntryParser()Creates a new MVSFTPEntryParser.FTPFileEntryParsercreateNetwareFTPEntryParser()Creates a new NetwareFTPEntryParser.FTPFileEntryParsercreateNTFTPEntryParser()Creates a new FTPFileEntryParser.private FTPFileEntryParsercreateNTFTPEntryParser(FTPClientConfig config)Creates an NT FTP parser: if the config exists, and the system key equalsFTPClientConfig.SYST_NTthen a plainNTFTPEntryParseris used, otherwise a composite ofNTFTPEntryParserandUnixFTPEntryParseris used.FTPFileEntryParsercreateOS2FTPEntryParser()Creates a new OS2FTPEntryParser.FTPFileEntryParsercreateOS400FTPEntryParser()Creates a new FTPFileEntryParser.private FTPFileEntryParsercreateOS400FTPEntryParser(FTPClientConfig config)Creates an OS400 FTP parser: if the config exists, and the system key equalsFTPClientConfig.SYST_OS400then a plainOS400FTPEntryParseris used, otherwise a composite ofOS400FTPEntryParserandUnixFTPEntryParseris used.FTPFileEntryParsercreateUnixFTPEntryParser()Creates a new UnixFTPEntryParser.FTPFileEntryParsercreateVMSVersioningFTPEntryParser()Creates a new VMSVersioningFTPEntryParser.
-
-
-
Field Detail
-
JAVA_IDENTIFIER
private static final java.lang.String JAVA_IDENTIFIER
Match a plain Java Identifier- See Also:
- Constant Field Values
-
JAVA_QUALIFIED_NAME
private static final java.lang.String JAVA_QUALIFIED_NAME
Match a qualified name, e.g. a.b.c.Name - but don't allow the default package as that would allow "VMS"/"UNIX" etc.- See Also:
- Constant Field Values
-
JAVA_QUALIFIED_NAME_PATTERN
private static final java.util.regex.Pattern JAVA_QUALIFIED_NAME_PATTERN
Create the pattern, as it will be reused many times
-
-
Method Detail
-
createFileEntryParser
public FTPFileEntryParser createFileEntryParser(FTPClientConfig config) throws ParserInitializationException
Implementation extracts a key from the suppliedFTPClientConfigparameter and creates an object implementing the interface FTPFileEntryParser and uses the supplied configuration to configure it.Note that this method will generally not be called in scenarios that call for autodetection of parser type but rather, for situations where the user knows that the server uses a non-default configuration and knows what that configuration is.
- Specified by:
createFileEntryParserin interfaceFTPFileEntryParserFactory- Parameters:
config- AFTPClientConfigused to configure the parser created- Returns:
- the
FTPFileEntryParserso created. - Throws:
ParserInitializationException- Thrown on any exception in instantiationjava.lang.NullPointerException- ifconfigisnull- Since:
- 1.4
-
createFileEntryParser
public FTPFileEntryParser createFileEntryParser(java.lang.String key)
This default implementation of the FTPFileEntryParserFactory interface works according to the following logic: First it attempts to interpret the supplied key as a fully qualified class name (default package is not allowed) of a class implementing the FTPFileEntryParser interface. If that succeeds, a parser object of this class is instantiated and is returned; otherwise it attempts to interpret the key as an identifier commonly used by the FTP SYST command to identify systems.If
keyis not recognized as a fully qualified class name known to the system, this method will then attempt to see whether it contains a string identifying one of the known parsers. This comparison is case-insensitive. The intent here is where possible, to select as keys strings which are returned by the SYST command on the systems which the corresponding parser successfully parses. This enables this factory to be used in the auto-detection system.- Specified by:
createFileEntryParserin interfaceFTPFileEntryParserFactory- Parameters:
key- should be a fully qualified class name corresponding to a class implementing the FTPFileEntryParser interface
OR
a string containing (case-insensitively) one of the following keywords:- Returns:
- the FTPFileEntryParser corresponding to the supplied key.
- Throws:
ParserInitializationException- thrown if for any reason the factory cannot resolve the supplied key into an FTPFileEntryParser.- See Also:
FTPFileEntryParser
-
createFileEntryParser
private FTPFileEntryParser createFileEntryParser(java.lang.String key, FTPClientConfig config)
-
createMVSEntryParser
public FTPFileEntryParser createMVSEntryParser()
Creates a new MVSFTPEntryParser.- Returns:
- a new MVSFTPEntryParser.
-
createNetwareFTPEntryParser
public FTPFileEntryParser createNetwareFTPEntryParser()
Creates a new NetwareFTPEntryParser.- Returns:
- a new NetwareFTPEntryParser.
-
createNTFTPEntryParser
public FTPFileEntryParser createNTFTPEntryParser()
Creates a new FTPFileEntryParser.- Returns:
- a new FTPFileEntryParser.
-
createNTFTPEntryParser
private FTPFileEntryParser createNTFTPEntryParser(FTPClientConfig config)
Creates an NT FTP parser: if the config exists, and the system key equalsFTPClientConfig.SYST_NTthen a plainNTFTPEntryParseris used, otherwise a composite ofNTFTPEntryParserandUnixFTPEntryParseris used.- Parameters:
config- the config to use, may benull- Returns:
- the parser
-
createOS2FTPEntryParser
public FTPFileEntryParser createOS2FTPEntryParser()
Creates a new OS2FTPEntryParser.- Returns:
- a new OS2FTPEntryParser.
-
createOS400FTPEntryParser
public FTPFileEntryParser createOS400FTPEntryParser()
Creates a new FTPFileEntryParser.- Returns:
- a new FTPFileEntryParser.
-
createOS400FTPEntryParser
private FTPFileEntryParser createOS400FTPEntryParser(FTPClientConfig config)
Creates an OS400 FTP parser: if the config exists, and the system key equalsFTPClientConfig.SYST_OS400then a plainOS400FTPEntryParseris used, otherwise a composite ofOS400FTPEntryParserandUnixFTPEntryParseris used.- Parameters:
config- the config to use, may benull- Returns:
- the parser
-
createUnixFTPEntryParser
public FTPFileEntryParser createUnixFTPEntryParser()
Creates a new UnixFTPEntryParser.- Returns:
- a new UnixFTPEntryParser.
-
createVMSVersioningFTPEntryParser
public FTPFileEntryParser createVMSVersioningFTPEntryParser()
Creates a new VMSVersioningFTPEntryParser.- Returns:
- a new VMSVersioningFTPEntryParser.
-
-