| java.lang.Object com.jidesoft.comparator.ObjectComparatorManager
ObjectComparatorManager | public class ObjectComparatorManager (Code) | | A global object that can register comparator with a type and a ComparatorContext.
|
Method Summary | |
public static void | addRegistrationListener(RegistrationListener l) Adds a listener to the list that's notified each time a change
to the manager occurs. | public static int | compare(Object o1, Object o2) Compares the two objects. | public static int | compare(Object o1, Object o2, ComparatorContext context) Compares the two objects. | public static int | compare(Object o1, Object o2, Class> clazz) Compares the two objects. | public static int | compare(Object o1, Object o2, Class> clazz, ComparatorContext context) Compares the two objects. | public static Comparator | getComparator(Class> clazz) Gets the registered comparator associated with class and default context.
Parameters: clazz - the data type. | public static Comparator | getComparator(Class> clazz, ComparatorContext context) Gets the comparator.
Parameters: clazz - the data type. Parameters: context - the comparator context. | public static ComparatorContext[] | getComparatorContexts(Class> clazz) Gets the available ComparatorContexts registered with the class.
Parameters: clazz - the class. | public static RegistrationListener[] | getRegistrationListeners() Returns an array of all the registration listeners
registered on this manager. | public static void | initDefaultComparator() Initialize default comparator. | public static boolean | isAutoInit() Checks the value of autoInit. | public static void | registerComparator(Class> clazz, Comparator comparator) | public static void | registerComparator(Class> clazz, Comparator comparator, ComparatorContext context) Registers a comparator with the type specified as class and a comparator context specified as context. | public static void | removeRegistrationListener(RegistrationListener l) Removes a listener from the list that's notified each time a
change to the manager occurs. | public static void | resetInit() If
ObjectComparatorManager.initDefaultComparator() is called once, calling it again will have no effect because an internal flag is set. | public static void | setAutoInit(boolean autoInit) Sets autoInit to true or false. | public static void | unregisterAllComparators() Unregisters all the comparators which registered before. | public static void | unregisterComparator(Class> clazz) Unregisters comparator associated with clazz and context. | public static void | unregisterComparator(Class> clazz, ComparatorContext context) Unregisters comparator associated with clazz and context. |
addRegistrationListener | public static void addRegistrationListener(RegistrationListener l)(Code) | | Adds a listener to the list that's notified each time a change
to the manager occurs.
Parameters: l - the RegistrationListener |
compare | public static int compare(Object o1, Object o2)(Code) | | Compares the two objects. It will look up in ObjectComparatorManager
to find the comparator and compare.
Parameters: o1 - the first object to be compared. Parameters: o2 - the second object to be compared. the compare result as defined in Comparator.compare(ObjectObject) |
compare | public static int compare(Object o1, Object o2, ComparatorContext context)(Code) | | Compares the two objects. It will look up in ObjectComparatorManager
to find the comparator and compare.
Parameters: o1 - the first object to be compared. Parameters: o2 - the second object to be compared. Parameters: context - the comparator context the compare result as defined in Comparator.compare(ObjectObject) |
compare | public static int compare(Object o1, Object o2, Class> clazz)(Code) | | Compares the two objects. It will look up in ObjectComparatorManager
to find the comparator and compare. This method needs a third parameter which is the data type.
This is useful when you have two objects that have different data types but both extend
the same super class. In this case, you may want the super class as the key to look up in
ObjectComparatorManager .
Parameters: o1 - the first object to be compared. Parameters: o2 - the second object to be compared. Parameters: clazz - the data type of the two objects. If your two objects have the same type, you may just use ObjectComparatorManager.compare(Object,Object) methods. the compare result as defined in Comparator.compare(ObjectObject) |
compare | public static int compare(Object o1, Object o2, Class> clazz, ComparatorContext context)(Code) | | Compares the two objects. It will look up in ObjectComparatorManager
to find the comparator and compare. If it is not found, we will convert the object to
string and compare the two strings.
Parameters: o1 - the first object to be compared. Parameters: o2 - the second object to be compared. Parameters: clazz - the data type of the two objects. If your two objects have the same type, you may just use ObjectComparatorManager.compare(Object,Object) methods. Parameters: context - the comparator context the compare result as defined in Comparator.compare(ObjectObject) |
getComparator | public static Comparator getComparator(Class> clazz)(Code) | | Gets the registered comparator associated with class and default context.
Parameters: clazz - the data type. the registered comparator. |
getComparator | public static Comparator getComparator(Class> clazz, ComparatorContext context)(Code) | | Gets the comparator.
Parameters: clazz - the data type. Parameters: context - the comparator context. the comparator. |
getComparatorContexts | public static ComparatorContext[] getComparatorContexts(Class> clazz)(Code) | | Gets the available ComparatorContexts registered with the class.
Parameters: clazz - the class. the available ComparatorContext. |
initDefaultComparator | public static void initDefaultComparator()(Code) | | Initialize default comparator. Please make sure you call this method
before you use any comparator related classes such as SortableTableModel.
|
registerComparator | public static void registerComparator(Class> clazz, Comparator comparator, ComparatorContext context)(Code) | | Registers a comparator with the type specified as class and a comparator context specified as context.
Parameters: clazz - type. Parameters: comparator - the comparator to be registered. Parameters: context - the comparator context. |
removeRegistrationListener | public static void removeRegistrationListener(RegistrationListener l)(Code) | | Removes a listener from the list that's notified each time a
change to the manager occurs.
Parameters: l - the RegistrationListener |
setAutoInit | public static void setAutoInit(boolean autoInit)(Code) | | Sets autoInit to true or false. If autoInit is true, whenever someone tries to call methods like
as toString or fromString,
ObjectComparatorManager.initDefaultComparator() will be called if it has never be called.
By default, autoInit is true.
This might affect the behavior if users provide their own comparators and want to overwrite
default comparators. In this case, instead of depending on autoInit to initialize default comparators,
you should call
ObjectComparatorManager.initDefaultComparator() first, then call registerComparator to add your own comparators.
Parameters: autoInit - false if you want to disable autoInit which means you either don'twant those default comparators registered or you will call ObjectComparatorManager.initDefaultComparator() yourself. |
unregisterAllComparators | public static void unregisterAllComparators()(Code) | | Unregisters all the comparators which registered before.
|
unregisterComparator | public static void unregisterComparator(Class> clazz)(Code) | | Unregisters comparator associated with clazz and context.
Parameters: clazz - the data type. |
unregisterComparator | public static void unregisterComparator(Class> clazz, ComparatorContext context)(Code) | | Unregisters comparator associated with clazz and context.
Parameters: clazz - the data type. Parameters: context - the comparator context. |
|
|