Package org.smooks.api.resource.config
Interface ResourceConfigSortComparator
-
- All Superinterfaces:
Comparator<ResourceConfig>
- All Known Implementing Classes:
DefaultResourceConfigSortComparator
public interface ResourceConfigSortComparator extends Comparator<ResourceConfig>
Sort Comparator forResourceConfig
Objects based on their "specificity". Before reading this be sure to read theResourceConfig
class Javadoc. As Smooks appliesContentHandler
s (DOMElementVisitors
andSerializationUnits
) it may discover that in a given case more than 1ContentHandler
can be applied. How does Smooks decide on the order in which theseContentHandler
s are to be applied to the content? At the moment, Smooks uses this class to calculate a "specificity" rating for each Content Delivery Resource based on its<smooks-resource>
configuration, and sorts them in decreasing order of specificity. The following outlines how this specificity value is calculated at present.// Get the combined specificity of all the profile targeting expressions.
For more details on this please refer to the code in this class.ProfileTargetingExpression
[] profileTargetingExpressions = resourceConfig.getProfileTargetingExpressions()
; for(int i = 0; i < profileTargetingExpressions.length; i++) { specificity += profileTargetingExpressions[i].getSpecificity(profileSet)
; } // Check the 'selector' attribute value. if (resourceConfig.getselector()
.equals("*")) { specificity += 5; } else { // Explicit selector listed specificity += 100; // If the selector is contextual it's, therefore more specific so // account for that. Subtract 1 because that "1" is already accounted // for by the addition of 100 - it's the extra we're accounting for here... if(resourceConfig.isSelectorContextual()) { int contextSpecificity = resourceConfig.getContextualSelector().length; specificity += (10 * (contextSpecificity - 1)); } } // Check the 'namespace' attribute. if(resourceConfig.getSelectorNamespaceURI()
!= null) { specificity += 10; }- Author:
- tfennelly
-
-
Method Summary
-
Methods inherited from interface java.util.Comparator
compare, equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-