Package ua.pp.bizon.cripto.file

Source Code of ua.pp.bizon.cripto.file.FileFactory

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);
    }

}
TOP

Related Classes of ua.pp.bizon.cripto.file.FileFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.