public class SmooksResourceConfigurationSortComparator extends Object implements Comparator
SmooksResourceConfiguration Objects based on their "specificity".
 
 Before reading this be sure to read the SmooksResourceConfiguration class Javadoc.
 
 As Smooks applies ContentHandlers (DOMElementVisitors and
 SerializationUnits) it may discover that in a given case more than 1 ContentHandler
 can be applied.  How does Smooks decide on the order in which these ContentHandlers 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.
        ProfileTargetingExpression[] profileTargetingExpressions = resourceConfig.getProfileTargetingExpressions();
        for(int i = 0; i < profileTargetingExpressions.length; i++) {
                specificity += profileTargetingExpressions[i].getSpecificity(profileSet);
        }
        
        // Check the 'selector' attribute value.
        if(resourceConfig.isXmlDef()) {
                specificity += 10;
        } else 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;
        }  
 For more details on this please refer to the code in this class.| Constructor and Description | 
|---|
| SmooksResourceConfigurationSortComparator(ProfileSet profileSet)Private constructor. | 
| Modifier and Type | Method and Description | 
|---|---|
| int | compare(Object configObj1,
       Object configObj2) | 
| protected double | getSpecificity(SmooksResourceConfiguration resourceConfig)Get the specificity of the SmooksResourceConfiguration. | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic SmooksResourceConfigurationSortComparator(ProfileSet profileSet)
profileSet - Profile set used to evaluate specificity.public int compare(Object configObj1, Object configObj2)
compare in interface Comparatorprotected double getSpecificity(SmooksResourceConfiguration resourceConfig)
resourceConfig - Resource configuration.Copyright © 2020. All rights reserved.