Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.sbugs.logic
Class BeanComparator  view BeanComparator download BeanComparator.java

java.lang.Object
  extended byorg.sbugs.logic.BeanComparator
All Implemented Interfaces:
java.util.Comparator

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


Field Summary
private  java.lang.Class beanClass
           
private  java.lang.String comparePropName
           
private static java.lang.Object[] emptyArgs
           
private  java.lang.reflect.Method propertyMethod
           
 
Constructor Summary
protected BeanComparator(java.lang.String comparePropName, java.lang.Class beanClass)
           
 
Method Summary
 int compare(java.lang.Object obj1, java.lang.Object obj2)
          Return an integer that is negative, zero or positive depending on whether the first argument is less than, equal to or greater than the second according to this ordering.
protected  int compareResults(java.lang.Object res1, java.lang.Object res2)
           
 java.lang.Class getBeanClass()
           
 java.lang.String getComparePropName()
           
static BeanComparator getInstance(java.lang.String propName, java.lang.Class beanClass)
           
protected  java.lang.reflect.Method getPropertyMethod()
           
 void setBeanClass(java.lang.Class clazz)
           
 void setComparePropName(java.lang.String propName)
           
 
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
 

Field Detail

comparePropName

private java.lang.String comparePropName

beanClass

private java.lang.Class beanClass

propertyMethod

private java.lang.reflect.Method propertyMethod

emptyArgs

private static java.lang.Object[] emptyArgs
Constructor Detail

BeanComparator

protected BeanComparator(java.lang.String comparePropName,
                         java.lang.Class beanClass)
Method Detail

setComparePropName

public void setComparePropName(java.lang.String propName)

getComparePropName

public java.lang.String getComparePropName()

setBeanClass

public void setBeanClass(java.lang.Class clazz)

getBeanClass

public java.lang.Class getBeanClass()

getInstance

public static BeanComparator getInstance(java.lang.String propName,
                                         java.lang.Class beanClass)

compare

public int compare(java.lang.Object obj1,
                   java.lang.Object obj2)
Description copied from interface: java.util.Comparator
Return an integer that is negative, zero or positive depending on whether the first argument is less than, equal to or greater than the second according to this ordering. This method should obey the following contract:
  • if compare(a, b) < 0 then compare(b, a) > 0
  • if compare(a, b) throws an exception, so does compare(b, a)
  • if compare(a, b) < 0 and compare(b, c) < 0 then compare(a, c) < 0
  • if compare(a, b) == 0 then compare(a, c) and compare(b, c) must have the same sign
To be consistent with equals, the following additional constraint is in place:
  • if a.equals(b) or both a and b are null, then compare(a, b) == 0.

Although it is permissible for a comparator to provide an order inconsistent with equals, that should be documented.

Specified by:
compare in interface java.util.Comparator

compareResults

protected int compareResults(java.lang.Object res1,
                             java.lang.Object res2)

getPropertyMethod

protected java.lang.reflect.Method getPropertyMethod()
                                              throws java.lang.NoSuchMethodException,
                                                     java.lang.SecurityException