1 32 33 package com.knowgate.lucene; 34 35 import java.util.Date ; 36 import java.util.Comparator ; 37 import java.text.SimpleDateFormat ; 38 39 43 public class MailRecord { 44 45 public static class CompareAuthor implements Comparator { 46 public int compare(Object o1, Object o2) { 47 if (((MailRecord)o1).getAuthor()==null) return -1; 48 return ((MailRecord)o1).getAuthor().compareTo(((MailRecord)o2).getAuthor()); 49 } 50 } 51 52 public static class CompareSubject implements Comparator { 53 public int compare(Object o1, Object o2) { 54 if (((MailRecord)o1).getSubject()==null) return -1; 55 return ((MailRecord)o1).getSubject().compareTo(((MailRecord)o2).getSubject()); 56 } 57 } 58 59 public static class CompareDateSent implements Comparator { 60 public int compare(Object o1, Object o2) { 61 if (((MailRecord)o1).getDateSent()==null) return -1; 62 return ((MailRecord)o1).getDateSent().compareTo(((MailRecord)o2).getDateSent()); 63 } 64 } 65 66 public static class CompareSize implements Comparator { 67 public int compare(Object o1, Object o2) { 68 return ((MailRecord)o1).getSize() - ((MailRecord)o2).getSize(); 69 } 70 } 71 72 public static class CompareFolder implements Comparator { 73 public int compare(Object o1, Object o2) { 74 if (((MailRecord)o1).getFolderName()==null) return -1; 75 return ((MailRecord)o1).getFolderName().compareTo(((MailRecord)o2).getFolderName()); 76 } 77 } 78 79 private static SimpleDateFormat fmt = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss"); 80 private String guid; 81 private String subject; 82 private String author; 83 private String size; 84 private String number; 85 private String folder; 86 private Date created; 87 88 public MailRecord() { } 89 90 public MailRecord(String sGuid, String sSubject, String sAuthor, String sDate, 91 String sSize, String sNumber, String sFolder) { 92 guid = sGuid; 93 subject = sSubject; 94 author = sAuthor; 95 try { created = fmt.parse(sDate); } catch (Exception ignore) {} 96 size = sSize; 97 number = sNumber; 98 folder = sFolder; 99 } 100 101 public String getFolderName() { 102 return folder; 103 } 104 105 public Date getDateSent() { 106 return created; 107 } 108 109 public int getNumber() throws NumberFormatException { 110 return Integer.parseInt(number); 111 } 112 113 public int getSize() throws NumberFormatException { 114 return Integer.parseInt(size); 115 } 116 117 public String getGuid() { 118 return guid; 119 } 120 121 public String getSubject() { 122 return subject; 123 } 124 125 public String getAuthor() { 126 return author; 127 } 128 129 public Date getDateCreated() { 130 return created; 131 } 132 133 public String getDateCreatedAsString() { 134 return fmt.format(created); 135 } 136 137 public void setFolderName(String sFolderName) { 138 folder = sFolderName; 139 } 140 141 public void setGuid(String sGuid) { 142 guid = sGuid; 143 } 144 145 public void setSubject(String sSubject) { 146 subject = sSubject; 147 } 148 149 public void setAuthor(String sAuthor) { 150 author = sAuthor; 151 } 152 153 public void setDateCreated(Date oDtCreated) { 154 created = oDtCreated; 155 } 156 } 157 | Popular Tags |