mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 03:45:35 +02:00
Return instance of UnixFTPEntryParser(default) when no registered parser found
This commit is contained in:
parent
952adeb56a
commit
ff38283964
1 changed files with 10 additions and 19 deletions
|
@ -18,6 +18,7 @@ import java.util.regex.Pattern;
|
||||||
import org.apache.commons.net.ftp.FTPClientConfig;
|
import org.apache.commons.net.ftp.FTPClientConfig;
|
||||||
import org.apache.commons.net.ftp.FTPFileEntryParser;
|
import org.apache.commons.net.ftp.FTPFileEntryParser;
|
||||||
import org.apache.commons.net.ftp.parser.ParserInitializationException;
|
import org.apache.commons.net.ftp.parser.ParserInitializationException;
|
||||||
|
import org.apache.commons.net.ftp.parser.UnixFTPEntryParser;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
@ -32,6 +33,7 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
private Hashtable ftpConfigProxyById = new Hashtable();
|
private Hashtable ftpConfigProxyById = new Hashtable();
|
||||||
private Hashtable ftpParsers = new Hashtable();
|
private Hashtable ftpParsers = new Hashtable();
|
||||||
private IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.subsystems.files.ftp","ftpListingParsers"); //$NON-NLS-1$ //$NON-NLS-2$
|
private IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.subsystems.files.ftp","ftpListingParsers"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
private UnixFTPEntryParser defaultFTPEntryParser = new UnixFTPEntryParser();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor of the parser factory
|
* Constructor of the parser factory
|
||||||
|
@ -209,29 +211,18 @@ public class FTPClientConfigFactory implements IFTPClientConfigFactory {
|
||||||
*/
|
*/
|
||||||
public FTPFileEntryParser createFileEntryParser(String key) throws ParserInitializationException {
|
public FTPFileEntryParser createFileEntryParser(String key) throws ParserInitializationException {
|
||||||
|
|
||||||
//
|
FTPFileEntryParser entryParser = null;
|
||||||
// the hashtable "ftpFileEntryParser" will be populated previously by getFTPClientConfig()
|
|
||||||
// but in case the execution flow gets modified it's worth checking and populating it if required
|
|
||||||
//
|
|
||||||
if(!ftpParsers.containsKey(key))
|
if(!ftpParsers.containsKey(key))
|
||||||
{
|
{
|
||||||
FTPClientConfigProxy proxy = (FTPClientConfigProxy)ftpConfigProxyById.get(key);
|
entryParser = defaultFTPEntryParser;
|
||||||
|
}
|
||||||
FTPFileEntryParser entryParser = null;
|
else
|
||||||
try {
|
{
|
||||||
entryParser = (FTPFileEntryParser)proxy.getDeclaringBundle().loadClass(proxy.getClassName()).newInstance();
|
entryParser = (FTPFileEntryParser)ftpParsers.get(key);
|
||||||
} catch (InstantiationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
ftpParsers.put(proxy.getClassName(), entryParser);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return entryParser;
|
||||||
return (FTPFileEntryParser)ftpParsers.get(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue