Abstract resource class.
addPath
public abstract Resource addPath(String path)
throws IOException,
MalformedURLException
Returns the resource contained inside the current resource with the
given name.
path
- The path segment to add, which should be encoded by the
encode method.
delete
public abstract boolean delete()
throws SecurityException
Deletes the given resource
encode
public String encode(String uri)
Encode according to this resource type.
The default implementation calls URI.encodePath(uri)
- String encoded for this resource type.
exists
public abstract boolean exists()
Returns true if the respresened resource exists.
finalize
protected void finalize()
getAlias
public URL getAlias()
- The canonical Alias of this resource or null if none.
getAssociate
public Object getAssociate()
getFile
public abstract File getFile()
throws IOException
Returns an File representing the given resource or NULL if this
is not possible.
getInputStream
public abstract InputStream getInputStream()
throws IOException
Returns an input stream to the resource
getListHTML
public String getListHTML(String base,
boolean parent)
throws IOException
Get the resource list as a HTML directory listing.
base
- The base URLparent
- True if the parent directory should be included
getName
public abstract String getName()
Returns the name of the resource
getOutputStream
public abstract OutputStream getOutputStream()
throws IOException,
SecurityException
Returns an output stream to the resource
getURL
public abstract URL getURL()
Returns an URL representing the given resource
isDirectory
public abstract boolean isDirectory()
Returns true if the respresenetd resource is a container/directory.
If the resource is not a file, resources ending with "/" are
considered directories.
lastModified
public abstract long lastModified()
Returns the last modified time
length
public abstract long length()
Return the length of the resource
list
public abstract String[] list()
Returns a list of resource names contained in the given resource
The resource names are not URL encoded.
newResource
public static Resource newResource(String resource)
throws MalformedURLException,
IOException
Construct a resource from a string.
resource
- A URL or filename.
newResource
public static Resource newResource(URL url)
throws IOException
Construct a resource from a url.
newSystemResource
public static Resource newSystemResource(String resource)
throws IOException
Construct a system resource from a string.
The resource is tried as classloader resource before being
treated as a normal resource.
release
public abstract void release()
Release any resources held by the resource.
renameTo
public abstract boolean renameTo(Resource dest)
throws SecurityException
Rename the given resource
setAssociate
public void setAssociate(Object o)
writeTo
public void writeTo(OutputStream out,
long start,
long count)
throws IOException
out
- start
- First byte to writecount
- Bytes to write or -1 for all of them.