Update of /cvsroot/displaytag/display09/src/org/displaytag/util
In directory sc8-pr-cvs1:/tmp/cvs-serv14245/src/org/displaytag/util

Modified Files:
        LookupUtil.java RowCellSorter.java RowSorter.java 
Log Message:
fixed lookup of null properties, fixed sorting with null values

Index: LookupUtil.java
===================================================================
RCS file: /cvsroot/displaytag/display09/src/org/displaytag/util/LookupUtil.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** LookupUtil.java     29 Jun 2003 21:41:58 -0000      1.3
--- LookupUtil.java     15 Jul 2003 21:48:36 -0000      1.4
***************
*** 175,179 ****
                        lIndexOfMAPPEDDELIM = 
pName.indexOf(PropertyUtils.MAPPED_DELIM);
  
!                       if (pBean instanceof Map)
                        {
                                pBean = ((Map) pBean).get(pName);
--- 175,184 ----
                        lIndexOfMAPPEDDELIM = 
pName.indexOf(PropertyUtils.MAPPED_DELIM);
  
!                       if (pBean == null)
!                       {
!                               mLog.debug("Null property value for '" + 
pName.substring(0, lIndexOfNESTEDDELIM) + "'");
!                               return null;
!                       }
!                       else if (pBean instanceof Map)
                        {
                                pBean = ((Map) pBean).get(pName);

Index: RowCellSorter.java
===================================================================
RCS file: /cvsroot/displaytag/display09/src/org/displaytag/util/RowCellSorter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RowCellSorter.java  21 Jun 2003 12:34:50 -0000      1.1
--- RowCellSorter.java  15 Jul 2003 21:48:36 -0000      1.2
***************
*** 17,21 ****
         * logger
         */
!       private static Log mLog= LogFactory.getLog(RowCellSorter.class);
  
        /**
--- 17,21 ----
         * logger
         */
!       private static Log mLog = LogFactory.getLog(RowCellSorter.class);
  
        /**
***************
*** 23,27 ****
         */
        private int mColumnIndex;
!       
        /**
         * Field mAscending
--- 23,27 ----
         */
        private int mColumnIndex;
! 
        /**
         * Field mAscending
***************
*** 38,43 ****
        public RowCellSorter(int pColumnIndex, boolean pAscending)
        {
!               mColumnIndex= pColumnIndex;
!               mAscending= pAscending ? 1 : -1;
        }
  
--- 38,43 ----
        public RowCellSorter(int pColumnIndex, boolean pAscending)
        {
!               mColumnIndex = pColumnIndex;
!               mAscending = pAscending ? 1 : -1;
        }
  
***************
*** 59,75 ****
        {
  
!               Object lObj1= null;
!               Object lObj2= null;
  
                if (pObject1 instanceof Row)
                {
!                       lObj1= ((Row) pObject1).getCellList().get(mColumnIndex);
                }
                if (pObject2 instanceof Row)
                {
!                       lObj2= ((Row) pObject2).getCellList().get(mColumnIndex);
                }
  
!               return mAscending * ((Comparable) lObj1).compareTo(lObj2);
  
        }
--- 59,96 ----
        {
  
!               Object lObj1 = null;
!               Object lObj2 = null;
  
                if (pObject1 instanceof Row)
                {
!                       lObj1 = ((Row) pObject1).getCellList().get(mColumnIndex);
                }
                if (pObject2 instanceof Row)
                {
!                       lObj2 = ((Row) pObject2).getCellList().get(mColumnIndex);
                }
  
!               if (lObj1 instanceof Comparable && lObj2 instanceof Comparable)
!               {
!                       Comparable lComparable1 = (Comparable) lObj1;
!                       Comparable lComparable2 = (Comparable) lObj2;
!                       return mAscending * lComparable1.compareTo(lComparable2);
!               }
!               else if (lObj1 == null && lObj2 == null)
!               {
!                       return 0;
!               }
!               else if (lObj1 == null && lObj2 != null)
!               {
!                       return 1;
!               }
!               else if (lObj1 != null && lObj2 == null)
!               {
!                       return -1;
!               }
!               else
!               {
!                       throw new RuntimeException("Object is not a Comparable 
object");
!               }
  
        }

Index: RowSorter.java
===================================================================
RCS file: /cvsroot/displaytag/display09/src/org/displaytag/util/RowSorter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RowSorter.java      21 Jun 2003 12:34:50 -0000      1.1
--- RowSorter.java      15 Jul 2003 21:48:36 -0000      1.2
***************
*** 121,124 ****
--- 121,136 ----
                                return mAscending * 
lComparable1.compareTo(lComparable2);
                        }
+                       else if (lObj1 == null && lObj2 == null)
+                       {
+                               return 0;
+                       }
+                       else if (lObj1 == null && lObj2 != null)
+                       {
+                               return 1;
+                       }
+                       else if (lObj1 != null && lObj2 == null)
+                       {
+                               return -1;
+                       }
                        else
                        {




-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
displaytag-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-devel

Reply via email to