1 4 package com.openedit.users; 5 6 import java.util.Comparator ; 7 8 12 public class UserComparator implements Comparator 13 { 14 15 18 public int compare(Object inO1, Object inO2) 19 { 20 User low = (User)inO1; 21 User high = (User)inO2; 22 23 String lowlast = low.getLastName(); 24 String highlast = high.getLastName(); 25 26 if ( lowlast == null) 27 { 28 lowlast = ""; 29 } 30 if ( highlast == null) 31 { 32 highlast = ""; 33 } 34 int i = lowlast.compareTo(highlast); 35 if ( i == 0) 36 { 37 return checkFirst(low.getFirstName(),high.getFirstName()); 38 } 39 else 40 { 41 return i; 42 } 43 } 44 45 50 private int checkFirst(String inFirstName, String inFirstName2) 51 { 52 if ( inFirstName ==null) 53 { 54 inFirstName = ""; 55 } 56 if ( inFirstName2 == null) 57 { 58 inFirstName2 = ""; 59 } 60 return inFirstName.compareTo(inFirstName2); 61 } 62 63 } 64 | Popular Tags |