Resource Classes

Resource objects, like java.io.File objects, are lightweight "token" objects.

LocalResource objects wrap a java.io.File, and UrlResource objects wrap a java.net.URL.

All resource objects keep a reference to their ResourceServer and delegate many of their functions to it.

Resource objects are considered equal if they map to the same file or URL, and have the same resource server.

« Interface »
Resource
+ getName() : String
+ getVersion() : String
+ toAddress() : String
+ getInputStream() : InputStream
+ getLiveInputStream() : InputStream
ResourceBasics
# server : ResourceServer
# ResourceBasics(ResourceServer)
+ getVersion() : String
+ toAddress() : String
+ getInputStream() : InputStream
LocalResource
- file : File
+ LocalResource(ResourceServer, File)
+ getName() : String
+ getLiveInputStream() : InputStream
+ equals(Object) : boolean
UrlResource
- url : URL
+ UrlResource(ResourceServer, URL)
+ getName() : String
+ getLiveInputStream() : InputStream
+ equals(Object) : boolean
public abstract class ResourceBasics implements Resource {

    protected ResourceServer server;

    public String getVersion() {
        return server.getVersion(this);
    }

    public String toAddress() {
        return server.toAddress(this);
    }

    public InputStream getInputStream() throws IOException {
        return server.getInputStream(this);
    }
}
public class LocalResource extends ResourceBasics {
    private File file;

    public InputStream getLiveInputStream() throws IOException {
        return new FileInputStream(file);
    }

    public String getName() {
        return file.getName();
    }
}
public class UrlResource extends ResourceBasics {
    private URL url;

    public InputStream getLiveInputStream() throws IOException {
        return ((UrlResourceServer) server).getLiveInputStream(url);
    }

    public String getName() {
        return UrlResourceServer.getName(url);
    }
}