edu.internet2.middleware.grouper.ui
Class DefaultComparatorImpl

java.lang.Object
  extended by edu.internet2.middleware.grouper.ui.DefaultComparatorImpl
All Implemented Interfaces:
GrouperComparator, Serializable, Comparator

public class DefaultComparatorImpl
extends Object
implements GrouperComparator

Implementation of Comparator used for sorting potentially disparate objects. A context and a config (ResourceBundle) must be set before the Comparator is used. Stems always sort before Groups.

Each Object passed to the compare method is used to lookup a helper class, configured through media.properties, which returns an appropriate sort String for the Object.

The Grouper UI comes pre-configured with the following implementations:

comparator.helper.edu.internet2.middleware.grouper\
.Group                =edu.internet2.middleware.grouper.ui.GroupComparatorHelper
.GroupAsMap           =edu.internet2.middleware.grouper.ui.GroupComparatorHelper
.Stem                 =edu.internet2.middleware.grouper.ui.StemComparatorHelper
.StemAsMap            =edu.internet2.middleware.grouper.ui.StemComparatorHelper
.Subject              =edu.internet2.middleware.grouper.ui.StemComparatorHelper
.SubjectAsMap         =edu.internet2.middleware.grouper.ui.SubjectComparatorHelper
.Member               =edu.internet2.middleware.grouper.ui.SubjectComparatorHelper
.Membership           =edu.internet2.middleware.grouper.ui.SubjectComparatorHelper
.MembershipAsMap      =edu.internet2.middleware.grouper.ui.SubjectComparatorHelper
.SubjectPrivilegeAsMap=edu.internet2.middleware.grouper.ui.GroupOrStemComparatorHelper

Sites can provide their own implementation for a helper class e.g. for a local implementation of the Subject interface which has complex sorting logic. The object instance class name is looked up first. If a helper is not found and the object is an instance of Subject, then the Subject helper implementation will be used.

This implementation has not been profiled. The sorting used is that provided by the JDK, however, determining the String to sort an object by, may be expensive, the first time it is determined, if lazy instantiation of the object is used.

Version:
$Id: DefaultComparatorImpl.java,v 1.4 2009-08-12 04:52:14 mchyzer Exp $
Author:
Gary Brown.
See Also:
Serialized Form

Constructor Summary
DefaultComparatorImpl()
           
 
Method Summary
 int compare(Object arg0, Object arg1)
           
 void setContext(String context)
          Provide the context in which sorting is taking place.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

DefaultComparatorImpl

public DefaultComparatorImpl()
Method Detail

setContext

public void setContext(String context)
Description copied from interface: GrouperComparator
Provide the context in which sorting is taking place. Different atributes may be displayed according to context

Specified by:
setContext in interface GrouperComparator

compare

public int compare(Object arg0,
                   Object arg1)
Specified by:
compare in interface Comparator