org.dmdf.utils
Class GenericObjectComparator

java.lang.Object
  extended by org.dmdf.utils.GenericObjectComparator
All Implemented Interfaces:
java.util.Comparator

public class GenericObjectComparator
extends java.lang.Object
implements java.util.Comparator

Author:
Steven Wang

This class is a generic comparator, it support multi fields comparision. Because this is a comparator, it does not suppose throw exception, so for the introspection relation exceptions will wrap it up as an runtime exception. The caller should make sure the property path is right.


Nested Class Summary
static interface GenericObjectComparator.CompareSpec
           
 
Constructor Summary
GenericObjectComparator(GenericObjectComparator.CompareSpec spec)
           
GenericObjectComparator(GenericObjectComparator.CompareSpec[] specs)
           
GenericObjectComparator(java.lang.String fieldName)
           
GenericObjectComparator(java.lang.String[] fieldNames)
           
GenericObjectComparator(java.lang.String[] fieldNames, boolean asending)
           
GenericObjectComparator(java.lang.String fieldName, boolean asending)
           
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
           
static GenericObjectComparator.CompareSpec compareSpec(java.lang.String path, boolean asending)
           
 
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
 

Constructor Detail

GenericObjectComparator

public GenericObjectComparator(GenericObjectComparator.CompareSpec[] specs)

GenericObjectComparator

public GenericObjectComparator(GenericObjectComparator.CompareSpec spec)

GenericObjectComparator

public GenericObjectComparator(java.lang.String fieldName)

GenericObjectComparator

public GenericObjectComparator(java.lang.String fieldName,
                               boolean asending)

GenericObjectComparator

public GenericObjectComparator(java.lang.String[] fieldNames)

GenericObjectComparator

public GenericObjectComparator(java.lang.String[] fieldNames,
                               boolean asending)
Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Specified by:
compare in interface java.util.Comparator

compareSpec

public static GenericObjectComparator.CompareSpec compareSpec(java.lang.String path,
                                                              boolean asending)


Copyright © 2005 org.dmdt. All Rights Reserved.