|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This interface provides a simple interface for accessing a source of data.
When the Source
object is no longer needed
it must be released using the SourceResolver
. This is very similar to
looking up components from a ServiceSelector
.
In fact a source object can implement most lifecycle interfaces
like Composable, Initializable, Disposable etc.
The data content can be constant or change over time.
Using the getInputStream()
method you get always the up-to-date content.
If you want to track changes of the source object, this interface offers you some support for it by providing a SourceValidity object.
How does the caching work? The first time you get a Source object, you simply ask it for it's content via getInputStream() and then get the validity object by invoking getValidity. (Further calls to getValidity always return the same object! This is not updated!) The caching algorithm can now store this validity object together with the system identifier of the source. The next time, the caching algorithm wants to check if the cached content is still valid. It has a validity object already to check against.
If it is still the same Source than the first time, you have to call refresh() in order to discard the stored validity in the Source object. If it is a new Source object, calling refresh() should do no harm. After that an up-to-date validity object can retrieved by calling getValidity(). This can be used to test if the content is still valid as discribed in the source validity documentation. If the content is still valid, the cache knows what to do, if not, the new content can be get using getInputStream(). So either after a call to getValidity() or the getInputStream the validity object must be the same until refresh is called!
Method Summary | |
boolean |
exists()
Does this source exist ? |
long |
getContentLength()
Get the content length of this source's content or -1 if the length is unknown. |
java.io.InputStream |
getInputStream()
Return an InputStream to read from the source. |
long |
getLastModified()
Get the last modification date of this source. |
java.lang.String |
getMimeType()
Get the mime-type of the content described by this object. |
java.lang.String |
getScheme()
Return the URI scheme identifier, i.e. |
java.lang.String |
getURI()
Get the absolute URI for this source. |
SourceValidity |
getValidity()
Get the Validity object. |
void |
refresh()
Refresh the content of this object after the underlying data content has changed. |
Method Detail |
public boolean exists()
public java.io.InputStream getInputStream() throws java.io.IOException, SourceNotFoundException
InputStream
to read from the source.
This is the data at the point of invocation of this method,
so if this is Modifiable, you might get different content
from two different invocations.
The returned stream must be closed by the calling code.
InputStream
to read data from (never null
).
java.io.IOException
- if some I/O problem occurs.
SourceNotFoundException
- if the source doesn't exist.public java.lang.String getURI()
public java.lang.String getScheme()
This scheme can be used to get the SourceFactory
responsible for this object.
public SourceValidity getValidity()
If it is currently not possible to calculate such an information,
null
is returned.
null
.public void refresh()
Some implementations may cache some values to speedup sucessive calls. Refreshing ensures you get the latest information.
public java.lang.String getMimeType()
null
.
null
.public long getContentLength()
public long getLastModified()
0
if it's unknown.
0
.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |