/*
 * @author Ranides Atterwim {@literal <ranides@gmail.com>}
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.io.uri;

import java.io.IOException;
import java.net.URI;
import java.util.Collection;

/**
 * URIHandler interface should be implemented by classes which want to add suport for
 * specific URI schemes into URIResolver.
 *
 * URIHandler subclasses can register itself inside "META-INF/services"
 *
 * URIHandler subclasses can be registered manually by calling "register" method on resolver.
 *
 * @author Ranides Atterwim {@literal <ranides@gmail.com>}
 */
public interface URIHandler {

    /**
     * Creates new handle for specified URI.
     *
     * It is preferred to avoid I/O calls, but not obligatory.
     *
     * @param uri uri
     * @return handle
     * @throws IOException on error
     */
    URIHandle resolve(URI uri) throws IOException;

    /**
     * Returns immutable collection of all scheme prefixes supported by this handler.
     *
     * Scheme prefixes shouldn't inlcude ":" character.
     *
     * @return schemes
     */
    Collection<String> schemes();
    
}
