org.w3c.mwi.mobileok.basic
Class ResourceComparator

java.lang.Object
  extended by org.w3c.mwi.mobileok.basic.ResourceComparator
All Implemented Interfaces:
java.io.Serializable, java.util.Comparator<Resource>

final class ResourceComparator
extends java.lang.Object
implements java.util.Comparator<Resource>, java.io.Serializable

Compares Resources based on their context and their URI.

Version:
$Revision: 1.1 $
Author:
The W3C mobileOK Checker Task Force

Field Summary
static java.util.Comparator<Resource> INSTANCE
           
 
Constructor Summary
private ResourceComparator()
           
 
Method Summary
 int compare(Resource o1, Resource o2)
          Compares two resources based on the context of the resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

INSTANCE

public static final java.util.Comparator<Resource> INSTANCE
Constructor Detail

ResourceComparator

private ResourceComparator()
Method Detail

compare

public int compare(Resource o1,
                   Resource o2)
Compares two resources based on the context of the resources.

The following order is used:

  1. ResourceContext.Primary
  2. ResourceContext.Stylesheet
  3. ResourceContext.Image
  4. ResourceContext.Object
  5. ResourceContext.Linked
  6. other contexts

Stylesheets are also compared on their type:

  1. External
  2. Embedded
  3. Inline

Specified by:
compare in interface java.util.Comparator<Resource>
Parameters:
o1 - First resource to compare
o2 - Second resource to compare
Returns:
Comparison result between first and second resources, i.e. the result of (first - second).