package net.gotev.uploadservice.schemehandlers;

import java.lang.reflect.InvocationTargetException;
import java.util.LinkedHashMap;
import java.util.Map;
/* loaded from: classes.dex */
public class SchemeHandlerFactory {
    private LinkedHashMap<String, Class<? extends SchemeHandler>> handlers;

    /* loaded from: classes.dex */
    private static class LazyHolder {
        private static final SchemeHandlerFactory INSTANCE = new SchemeHandlerFactory();

        private LazyHolder() {
        }
    }

    public static SchemeHandlerFactory getInstance() {
        return LazyHolder.INSTANCE;
    }

    private SchemeHandlerFactory() {
        LinkedHashMap<String, Class<? extends SchemeHandler>> linkedHashMap = new LinkedHashMap<>();
        this.handlers = linkedHashMap;
        linkedHashMap.put("/", FileSchemeHandler.class);
        this.handlers.put("content://", ContentSchemeHandler.class);
    }

    public SchemeHandler get(String str) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        for (Map.Entry<String, Class<? extends SchemeHandler>> entry : this.handlers.entrySet()) {
            if (str.startsWith(entry.getKey())) {
                SchemeHandler newInstance = entry.getValue().newInstance();
                newInstance.init(str);
                return newInstance;
            }
        }
        throw new UnsupportedOperationException("No handlers for " + str);
    }

    public boolean isSupported(String str) {
        for (String str2 : this.handlers.keySet()) {
            if (str.startsWith(str2)) {
                return true;
            }
        }
        return false;
    }
}
