1 16 package org.apache.commons.vfs.provider.ftp; 17 18 import org.apache.commons.net.ftp.parser.FTPFileEntryParserFactory; 19 import org.apache.commons.vfs.FileSystemConfigBuilder; 20 import org.apache.commons.vfs.FileSystemOptions; 21 22 27 public class FtpFileSystemConfigBuilder extends FileSystemConfigBuilder 28 { 29 private final static FtpFileSystemConfigBuilder builder = new FtpFileSystemConfigBuilder(); 30 31 private final static String FACTORY_KEY = FTPFileEntryParserFactory.class.getName() + ".KEY"; 32 private final static String PASSIVE_MODE = FtpFileSystemConfigBuilder.class.getName() + ".PASSIVE"; 33 private final static String USER_DIR_IS_ROOT = FtpFileSystemConfigBuilder.class.getName() + ".USER_DIR_IS_ROOT"; 34 private final static String DATA_TIMEOUT = FtpFileSystemConfigBuilder.class.getName() + ".DATA_TIMEOUT"; 35 36 public static FtpFileSystemConfigBuilder getInstance() 37 { 38 return builder; 39 } 40 41 private FtpFileSystemConfigBuilder() 42 { 43 } 44 45 51 public void setEntryParserFactory(FileSystemOptions opts, FTPFileEntryParserFactory factory) 52 { 53 setParam(opts, FTPFileEntryParserFactory.class.getName(), factory); 54 } 55 56 61 public FTPFileEntryParserFactory getEntryParserFactory(FileSystemOptions opts) 62 { 63 return (FTPFileEntryParserFactory) getParam(opts, FTPFileEntryParserFactory.class.getName()); 64 } 65 66 75 public void setEntryParser(FileSystemOptions opts, String key) 76 { 77 setParam(opts, FACTORY_KEY, key); 78 } 79 80 85 public String getEntryParser(FileSystemOptions opts) 86 { 87 return (String ) getParam(opts, FACTORY_KEY); 88 } 89 90 protected Class getConfigClass() 91 { 92 return FtpFileSystem.class; 93 } 94 95 101 public void setPassiveMode(FileSystemOptions opts, boolean passiveMode) 102 { 103 setParam(opts, PASSIVE_MODE, passiveMode ? Boolean.TRUE : Boolean.FALSE); 104 } 105 106 111 public Boolean getPassiveMode(FileSystemOptions opts) 112 { 113 return (Boolean ) getParam(opts, PASSIVE_MODE); 114 } 115 116 122 public void setUserDirIsRoot(FileSystemOptions opts, boolean userDirIsRoot) 123 { 124 setParam(opts, USER_DIR_IS_ROOT, userDirIsRoot ? Boolean.TRUE : Boolean.FALSE); 125 } 126 127 132 public Boolean getUserDirIsRoot(FileSystemOptions opts) 133 { 134 return (Boolean ) getParam(opts, USER_DIR_IS_ROOT); 135 } 136 137 142 public Integer getDataTimeout(FileSystemOptions opts) 143 { 144 return (Integer ) getParam(opts, DATA_TIMEOUT); 145 } 146 147 155 public void setDataTimeout(FileSystemOptions opts, Integer dataTimeout) 156 { 157 setParam(opts, DATA_TIMEOUT, dataTimeout); 158 } 159 } 160 | Popular Tags |