package ua.pp.bizon.cripto.file;
import ua.pp.bizon.cripto.utils.FileUtilFtpImpl;
import ua.pp.bizon.cripto.utils.FileUtilLocalImpl;
public class FileFactory {
public static IPath getLocalFile(String path) {
return new FileUtilLocalImpl(path);
}
public static IPath getRemoteFile(String host, String user, String password, String path) {
return new FileUtilFtpImpl(path, user, password, host);
}
public static IPath parse(String substring) {
if (substring.startsWith("ftp://")){/* ftp://user:pass@host.com/path */
// TODO add ftp://ftp_config_url_name/path
String username = substring.substring(6, substring.indexOf(':', 6));
String password = substring.substring(substring.indexOf(':', 6) + 1, substring.indexOf('@'));
String host = substring.substring(substring.indexOf('@') + 1, substring.indexOf('/', 6));
String path = substring.substring(substring.indexOf('/', 6) + 1);
return getRemoteFile(host, username, password, path);
} else return getLocalFile(substring);
}
}