|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DataResource
This is the interface for a resource potentially
containing
data. You can think of a DataResource
as a file
but it may come from other sources than the filesystem.
The major reason for naming it DataResource
is that
Resource
is a very general name already occupied by
Resource
.
Method Summary | |
---|---|
Date |
getLastModificationDate()
This method gets the last modification date of the DataResource if
available and supported. |
String |
getName()
This method gets the name of the resource. |
String |
getPath()
This method gets the path of this resource. |
long |
getSize()
This method gets the size (content-length) of this resource. |
String |
getUri()
This method gets a string identifying this DataResource . |
URL |
getUrl()
This method gets this resource as URL . |
boolean |
isAvailable()
This method determines if this resource is available. |
boolean |
isData()
This method determines if this resource has potentially data available . |
Boolean |
isModifiedSince(Date date)
This method determines if this resource has been been modified since the given data . |
DataResource |
navigate(String resourcePath)
This method creates a new DataResource pointing to the given
resourcePath based on this resource. |
OutputStream |
openOutputStream()
This method opens an output-stream in order to write data to the resource. |
InputStream |
openStream()
This method opens this resource for reading. |
Method Detail |
---|
boolean isAvailable()
data can be read
.isData()
to prevent such expensive operaitons.
true
if this resource is available, false
otherwise.boolean isData()
available
. Unlike isAvailable()
this method
will not invoke expensive operations like connecting to remote URLs. If
this method will return false
, then isAvailable()
would also have returned false
. However in case of
true
only isAvailable()
can guarantee if a resource
really exists and contains data. E.g. if the resource points to a
File
then this method can check if it is a
data-file
. So in case it points to a
directory or does not exist at all in the filesystem, this method will
return false
. Please also note that this may invoke expensive
operations if the according directory path points to something like a
network share. You should also be aware that the state of isData()
and isAvailable()
can change at any time so you never have a full
guarantee if some data exists or NOT. However in most cases it is very
improbable that this status changes when you read
the
resource immediately after the check.
true
if this resource points to potential data,
false
otherwise.String getPath()
name
of the resource.created
.
String getName()
filename
.
long getSize() throws ResourceNotAvailableException
ResourceNotAvailableException
- if this resource is NOT
available
.URL getUrl() throws ResourceNotAvailableException
URL
.
ResourceNotAvailableException
- if an URL can NOT be created because
the represented resource does not exist.String getUri()
DataResource
. In most
cases this will be the same as string-representation
of the URL
. However this method
will not throw an exception.
InputStream openStream() throws ResourceNotAvailableException, RuntimeIoException
ResourceNotAvailableException
- if this resource is NOT
available
.
RuntimeIoException
- if an input/output error occurred.URL.openStream()
OutputStream openOutputStream() throws ResourceNotAvailableException, ResourceNotWritableException, RuntimeIoException
OutputStream
to write to the resource.
ResourceNotAvailableException
- if this resource is NOT
available
.
ResourceNotWritableException
- if the resource is NOT writable (e.g.
read-only).
RuntimeIoException
- if an input/output error occurred.DataResource navigate(String resourcePath) throws ResourceUriUndefinedException
DataResource
pointing to the given
resourcePath
based on this resource.relativePath
would be "../apt/sources.list" the resulting
resource would point to "/etc/apt/sources.list".
resourcePath
- is the absolute or relative path pointing to a new
resource. If it is a relative path, it is interpreted relative to
the parent URI (directory) of this resource.
ResourceUriUndefinedException
- if the given
resourcePath
leads to an undefined or illegal URI.Date getLastModificationDate()
DataResource
if
available
and supported.
Date
or null
if not
available or supported.Boolean isModifiedSince(Date date)
data
.
date
- is the Date
to check for.
true
if the resource has been modified after the given
date
, false
if it has NOT been modified
after the given date
and null
if this can
NOT be determined (resource not available
or
operation NOT supported by this resource).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |