1 4 package org.roller.pojos; 5 6 import java.io.Serializable ; 7 import java.util.Comparator ; 8 9 16 public class WeblogEntryComparator implements Comparator , Serializable 17 { 18 static final long serialVersionUID = -9067148992322255150L; 19 20 public int compare(Object val1, Object val2) 21 throws ClassCastException 22 { 23 WeblogEntryData entry1 = (WeblogEntryData)val1; 24 WeblogEntryData entry2 = (WeblogEntryData)val2; 25 long pubTime1 = entry1.getPubTime().getTime(); 26 long pubTime2 = entry2.getPubTime().getTime(); 27 28 if (pubTime1 > pubTime2) 29 { 30 return -1; 31 } 32 else if (pubTime1 < pubTime2) 33 { 34 return 1; 35 } 36 37 return entry1.getTitle().compareTo(entry2.getTitle()); 40 } 41 } 42 | Popular Tags |