|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.w3c.mwi.mobileok.basic.ObjectResourceExtractor
public class ObjectResourceExtractor
Extracts resources defined within object
elements in the given
XHTML resource, and resources defined in img
elements that
appear as the fallback content of an object
element that would
not be rendered by browsers.
In practice, the class implements the Object Element Processing Rule defined in the W3C mobileOK Basic Tests 1.0 specification.
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
.
Field Summary | |
---|---|
private java.util.Collection<java.net.URI> |
extractedImageUris
Internal list of extracted image URIs. |
private java.util.List<Resource> |
knownResources
List of resources already retrieved. |
private int |
resourceDepth
Depth of the resource bein parsed. |
Constructor Summary | |
---|---|
ObjectResourceExtractor()
Default constructor. |
Method Summary | |
---|---|
private void |
extractImages(org.w3c.dom.Element parent,
java.net.URI baseURI)
Extracts yet-unknown URIs of images that are direct children of the given object element, but that are not children of another
object element. |
private java.util.List<Resource> |
extractObjectsResources(java.util.List<org.w3c.dom.Node> topLevelObjects,
java.net.URI baseURI)
Recursive method to extract the list of objects resources that are referenced by the given objects and that need to be retrieved to render the given list of objects. |
java.util.List<Resource> |
extractResources(Resource resource,
java.util.List<Resource> knownResources)
Extracts additional resources from the given one. |
private java.util.List<org.w3c.dom.Node> |
getTopLevelObjects(org.w3c.dom.Element parent)
Returns the list of first generation object elements that
are children of the given Element , skipping any
intermediary markup. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.Collection<java.net.URI> extractedImageUris
private java.util.List<Resource> knownResources
private int resourceDepth
Constructor Detail |
---|
public ObjectResourceExtractor()
Method Detail |
---|
public java.util.List<Resource> extractResources(Resource resource, java.util.List<Resource> knownResources)
ResourceExtractor
The extracted resources may contain resources that have already been previously extracted, but known resources should not be automatically copied to the returned list.
extractResources
in interface ResourceExtractor
resource
- resource to parse.knownResources
- list of known resources.
null
when no resources were extracted.private java.util.List<Resource> extractObjectsResources(java.util.List<org.w3c.dom.Node> topLevelObjects, java.net.URI baseURI)
Recursive parsing is needed for object
elements
because of the possibility to define fallback mechanisms.
Note the function needs to access the tester configuration per-thread singleton. Since extraction is typically done using multithreading, make sure the singleton is set in the thread that calls this function!
topLevelObjects
- the list of top-level-objects known at this level.baseURI
- base URI against which relative URIS should be resolved.
private java.util.List<org.w3c.dom.Node> getTopLevelObjects(org.w3c.dom.Element parent)
object
elements that
are children of the given Element
, skipping any
intermediary markup.
parent
- Element
to parse.
object
elements in given
Element
.private void extractImages(org.w3c.dom.Element parent, java.net.URI baseURI)
object
element, but that are not children of another
object
element.
Objects are parsed recursively. Each time the fallback content would be rendered by browsers, the images contained within this fallback content would be rendered as well, and need to be taken into account.
parent
- Object parent to parsebaseURI
- base URI against which relative URIS will be resolved.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |