org.w3c.mwi.mobileok.basic
Interface ResourceFactory


public interface ResourceFactory

Interface that must be implemented by resource factories.

A resource factory is used to create an instance of the appropriate derived class of Resource based on the content-type of the retrieved resource, and possibly on the context under which the resource is to be created.

When a resource couldn't be retrieved because of some network error, an instance of the RetrievalFailedResource class must be returned.

When a resource's content-type is not supported for the given context, an instance of the NotSupportedResource class must be returned.

Version:
$Revision: 1.1 $
Author:
Francois Daoust

Method Summary
 Resource createResource(java.net.URI uri, java.util.List<RetrievalElement> retrieved, int depth, ResourceContext resourceContext, Resource.LoadType loadType)
          Creates an instance of a Resource based on the given parameters.
 boolean isContentTypeSupported(java.lang.String contentType, ResourceContext resourceContext)
          Returns true when the factory is able to create resources that match the given content-type under the given context.
 

Method Detail

createResource

Resource createResource(java.net.URI uri,
                        java.util.List<RetrievalElement> retrieved,
                        int depth,
                        ResourceContext resourceContext,
                        Resource.LoadType loadType)
                        throws TestException
Creates an instance of a Resource based on the given parameters.

Parameters:
uri - absolute URI of the resource.
retrieved - the retrieved representation of the resource.
depth - the depth of the resource
resourceContext - the context that gave birth to the resource.
loadType - browser rendering type of the resource
Returns:
a Resource that best match the retrieved one, cannot be null.
Throws:
TestException - an unexpected error occurred while retrieving the resource.

isContentTypeSupported

boolean isContentTypeSupported(java.lang.String contentType,
                               ResourceContext resourceContext)
Returns true when the factory is able to create resources that match the given content-type under the given context.

Parameters:
contentType - Content-Type to check
resourceContext - Context under which the resource would be created
Returns:
true when the content-type is supported, false otherwise