|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ResourceTransportObject
This interface represents a reference to a resource that will be downloaded using an interaction channel transport service provider. It exposes a set of methods that correspond with those in org.dvb.dsmcc.DSMCCObject, so that the applications can use DSMCCObject to reference resources that will be downloaded by the GEM implementation via the service provider implementation.
Like DSMCCObject, ResourceTransportObject instances can either be in a loaded or unloaded state. When in a loaded state, the contents of the resource can be accessed either directly from memory as a byte array or else from a physical file in a local file system (could also be a RAM-based file system).
Note that unlike DSMCCObject instances, resource transport objects are only used to download resources with associated content (i.e. not for URIs that represent directories).
Field Summary | |
---|---|
static int |
LOAD_TYPE_FILE
Resource load type that indicates the file has been loaded to a local physical file system. |
static int |
LOAD_TYPE_MEMORY
Resource load type that indicates the file has been loaded in memory as a byte array. |
Method Summary | |
---|---|
void |
abort()
This method is used to abort a load in progress. |
void |
addUpdateListener(ResourceUpdateListener listener)
Add a listener to receive notifications of updates to this resource. |
void |
asynchronousLoad(AsyncResourceLoadListener listener)
Load the resource asynchronously. |
boolean |
exists()
Return a flag indicating whether the resource exists. |
long |
getLength()
Return the length in bytes of content of this resource. |
java.lang.String |
getMimeType()
Return the MIME type of the resource. |
byte[] |
getResourceBytes()
Return a byte array containing the downloaded resource. |
java.io.File |
getResourceFile()
Return the resource file containing the downloaded resource. |
int |
getResourceLoadType()
Return a value indicating where the associated resource has been downloaded. |
java.lang.String |
getURI()
Return the URI identifying the resource to be downloaded. |
boolean |
isLoaded()
Return a flag indicating whether the resource has been succesfully downloaded. |
boolean |
isMetadataLoaded()
Return a flag indicating whether the metadata for this resource (existence flag, content length, and MIME type) is available for retrieval via the corresponding accessor methods. |
void |
loadMetadata(AsyncResourceLoadListener listener)
Load the resource metadata (existence flag, content length, and MIME type) for this resource. |
void |
removeUpdateListener(ResourceUpdateListener listener)
Remove a listener that is currently receiving notifications of updates to this resource. |
void |
synchronousLoad()
Load the resource. |
void |
unload()
Tells the service provider that the downloaded resource object is no longer used, and therefore any resources allocated to this object can be freed. |
Field Detail |
---|
static final int LOAD_TYPE_MEMORY
static final int LOAD_TYPE_FILE
Method Detail |
---|
java.lang.String getURI()
void addUpdateListener(ResourceUpdateListener listener)
Once an object has successfully entered the loaded state once, this event shall continue to be fired when changes are detected regardless of further transitions in or out of the loaded state.
listener
- the listener to be addedvoid removeUpdateListener(ResourceUpdateListener listener)
listener
- the listener to be removedvoid synchronousLoad() throws ResourceLoadException
ResourceLoadException
void asynchronousLoad(AsyncResourceLoadListener listener)
listener
- the listener to be notifiedboolean isLoaded()
boolean isMetadataLoaded()
loadMetadata
method; that method should be
called only when this method returns false
.
int getResourceLoadType()
LOAD_TYPE_MEMORY
- indicates that the
resource was loaded into memory as a byte array, and can be
retrieved using the getResourceBytes()
method.
LOAD_TYPE_FILE
- indicates that the resource
was loaded to a file on a local physical file system, and can
be retrieved using the getResourceFile()
method.
java.lang.IllegalStateException
- if the resource is not loaded
java.io.File getResourceFile()
getResourceLoadType()
returns
LOAD_TYPE_FILE
.
The provider must ensure that the returned file is readable by the GEM implementation.
java.lang.IllegalStateException
- if the resource is not loaded
or is loaded to a byte array in
memorybyte[] getResourceBytes()
getResourceLoadType()
returns
LOAD_TYPE_MEMORY
.
java.lang.IllegalStateException
- if the resource is not loaded
or is loaded to a filevoid abort()
java.lang.IllegalStateException
- if load of the resource has not
already been startedvoid unload()
java.lang.IllegalStateException
- if the resource is not loadedvoid loadMetadata(AsyncResourceLoadListener listener) throws ResourceLoadException
asynchronousLoad()
.
If a load request is already in progress, this method may
also block until the outstanding load request is complete.
This method may fail either asynchronously with notification event sent to the listener or else synchronously during this method call.
Once the metadata is loaded, the following methods may be called:
exists()
getMimeType()
getLength()
listener
- A listener to be notified of asynchronous
loading events.
ResourceLoadException
boolean exists()
java.lang.String getMimeType()
long getLength()
getResourceBytes().length
or
getResourceFile().length()
, depending on the
load type.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |