org.w3c.mwi.mobileok.basic
Class LinkedResourceExtractor

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

public class LinkedResourceExtractor
extends java.lang.Object
implements ResourceExtractor

Extracts all linked resources from a given XHTML resource.

The notion of linked resource is to be understood as a resource linked to from the XHTML resource being parsed (other than the resource itself), but which does not take part in the rendering of that resource.

In practice, it means the resources identified by the href attribute of the a elements, and by the action attribute of form elements whose method attribute is set to "get" (or is not set).

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
LinkedResourceExtractor()
          Default constructor.
 
Method Summary
private  java.util.List<java.net.URI> extractLinks(java.net.URI baseURI, org.w3c.dom.Document theDOM)
          Extracts the list of URIs of the links defined 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

LinkedResourceExtractor

public LinkedResourceExtractor()
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.

extractLinks

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

Such links are defined in:

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.