org.w3c.mwi.mobileok.basic
Class ImageResourceExtractor

java.lang.Object
  extended by org.w3c.mwi.mobileok.basic.ImageResourceExtractor
All Implemented Interfaces:
ResourceExtractor

public class ImageResourceExtractor
extends java.lang.Object
implements ResourceExtractor

Extracts all image resources embedded in the given XHTML resource.

In practice, it means the resources identified by the src attribute of the img elements, except those that are defined as a potential fallback of object elements.

The specific case of img elements defined within object elements is handled in ObjectResourceExtractor, because the tests on images defined in the mobileOK specification only apply to images that would be take part of the final representation of the resource. See Included resources for more details.

URIs whose scheme is not supported are ignored. As far as mobileOK is concerned, this means that URIs must use the scheme HTTP or HTTPS, but note the code actually relies on the list of ResourceRetriever defined in TesterConfiguration.

Version:
$Revision: 1.1 $
Author:
Francois Daoust

Constructor Summary
ImageResourceExtractor()
          Default constructor.
 
Method Summary
private  java.util.List<java.net.URI> extractImages(java.net.URI baseURI, org.w3c.dom.Document theDOM)
          Extracts the list of URIs of the images referenced in the given DOM document.
 java.util.List<Resource> extractResources(Resource resource, java.util.List<Resource> knownResources)
          Extracts additional resources from the given one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageResourceExtractor

public ImageResourceExtractor()
Default constructor.

Method Detail

extractResources

public java.util.List<Resource> extractResources(Resource resource,
                                                 java.util.List<Resource> knownResources)
Description copied from interface: ResourceExtractor
Extracts additional resources from the given one.

The extracted resources may contain resources that have already been previously extracted, but known resources should not be automatically copied to the returned list.

Specified by:
extractResources in interface ResourceExtractor
Parameters:
resource - resource to parse.
knownResources - list of known resources.
Returns:
list of resources extracted from the resource to parse, null when no resources were extracted.

extractImages

private java.util.List<java.net.URI> extractImages(java.net.URI baseURI,
                                                   org.w3c.dom.Document theDOM)
Extracts the list of URIs of the images referenced in the given DOM document.

Such images are defined in the src attribute of the img elements.

Parameters:
baseURI - base URI against which relative URIS should be resolved.
theDOM - the DOM document to parse.
Returns:
the list of absolute URIs that identify the resources referenced by the DOM document.
Throws:
TestException - an unexpected error occurred.