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

import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.URI;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.time.Instant;
import java.util.Set;
import net.ranides.assira.collection.query.CQuery;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public interface URIHandle extends Closeable {
    
    static URIHandle resolve(String location) throws IOException {
        return URIResolver.DEFAULT.resolve(location);
    }
    
    static URIHandle resolve(File location) throws IOException {
        return URIResolver.DEFAULT.resolve(location);
    }
    
    static URIHandle resolve(URI location) throws IOException {
        return URIResolver.DEFAULT.resolve(location);
    }
    
    URIResolver resolver();
    
    URI uri() throws IOException;
    
    String scheme() throws IOException;
    
    File file() throws IOException;
    
    Path path() throws IOException;
    
    Charset charset() throws IOException;
    
    Set<URIFlags> flags() throws IOException;
    
    boolean exists() throws IOException;
    
    Instant time(URITime ut) throws IOException;
    
    long size() throws IOException;
    
    URIHandle parent() throws IOException;
    
    CQuery<URIHandle> scan() throws IOException;
    
    InputStream istream() throws IOException;
    
    InputStream istream(long offset) throws IOException;
    
    InputStream istream(long offset, long size) throws IOException;
    
    OutputStream ostream() throws IOException;
    
    Reader reader() throws IOException;
    
    Reader reader(Charset cs) throws IOException;
    
    Writer writer() throws IOException;
    
    Writer writer(Charset cs) throws IOException;
    
    void delete() throws IOException;
    
    void create() throws IOException;
    
    void move(String target) throws IOException;
    
    void move(URIHandle target) throws IOException;
    
    void copy(String target) throws IOException;
    
    void copy(URIHandle target) throws IOException;
    
}
