org.milyn.cdr
Class CDRDefSortComparator
java.lang.Object
org.milyn.cdr.CDRDefSortComparator
- All Implemented Interfaces:
- java.util.Comparator
- public class CDRDefSortComparator
- extends java.lang.Object
- implements java.util.Comparator
Sort Comparator for Unit def Objects based on their "specificity".
Before reading this be sure to read the CDRDef class Javadoc.
As Smooks applies ContentDeliveryUnits (AssemblyUnits, TransUnits and
SerializationUnits) it may discover that in a given case more than 1 ContentDeliveryUnit
can be applied. How does Smooks decide on the order in which these ContentDeliveryUnits are to be applied to the content?
At the moment, Smooks uses this class to calculate a "specificity" rating for each ContentDeliveryUnit based on its
<cdres> configuration and sorts the ContentDeliveryUnits in decreasing order of specificity.
The following outlines how this specificity value is calculated at present. This
"algorithm" wasn't arrived at through any real scientific process so it could
be very questionable:
// Check the 'uatarget' attribute value.
if(containsDevice(cdrDef.getUaTargets())) {
// Exact device listed
specificity += 10;
}
if(containsMatchingProfile(cdrDef.getUaTargets())) {
specificity += 5;
}
if(containsAstrix(cdrDef.getUaTargets())) {
specificity += 1;
}
// Check the 'selector' attribute value.
if(cdrDef.isXmlDef()) {
specificity += 1;
} else if(cdrDef.getselector().equals("*")) {
specificity += 5;
} else {
// Explicit selector listed
specificity += 10;
}
For more details on this please refer to the code in this class.
- Author:
- tfennelly
|
Method Summary |
int |
compare(java.lang.Object unitDefObj1,
java.lang.Object unitDefObj2)
|
| 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 |
CDRDefSortComparator
public CDRDefSortComparator(UAContext deviceContext)
- Private constructor.
- Parameters:
deviceContext - Device context.
compare
public int compare(java.lang.Object unitDefObj1,
java.lang.Object unitDefObj2)
- Specified by:
compare in interface java.util.Comparator