Source Code Cross Referenced for MessageSortingUtil.java in  » Web-Mail » Jwma » dtw » webmail » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Mail » Jwma » dtw.webmail.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /***
002:         * jwma Java WebMail
003:         * Copyright (c) 2000-2003 jwma team
004:         *
005:         * jwma is free software; you can distribute and use this source
006:         * under the terms of the BSD-style license received along with
007:         * the distribution.
008:         ***/package dtw.webmail.util;
009:
010:        import java.util.*;
011:
012:        import dtw.webmail.model.*;
013:
014:        /**
015:         * Utility class providing <tt>Comparator</tt>'s for
016:         * sorting messages applying different criterias.
017:         *
018:         * @author Dieter Wimberger
019:         * @version 0.9.7 07/02/2003
020:         */
021:        public class MessageSortingUtil {
022:
023:            /**
024:             * Defines a <tt>Comparator</tt> that sorts
025:             * the receive or sent date chronological (i.e. oldest first).
026:             */
027:            public static final Comparator DATE_CHRONOLOGICAL = new Comparator() {
028:
029:                public int compare(Object o1, Object o2) {
030:                    JwmaMessageInfo msg1 = (JwmaMessageInfo) o1;
031:                    JwmaMessageInfo msg2 = (JwmaMessageInfo) o2;
032:                    return msg1.getDate().compareTo(msg2.getDate());
033:                }//compare(Object,Object)
034:            };
035:
036:            /**
037:             * Defines a <tt>Comparator</tt> that sorts
038:             * the receive or sent date reverse to chronological
039:             * (i.e. most recent first).
040:             */
041:            public static final Comparator DATE_REVERSE_CHRONOLOGICAL = new Comparator() {
042:
043:                public int compare(Object o1, Object o2) {
044:                    JwmaMessageInfo msg1 = (JwmaMessageInfo) o1;
045:                    JwmaMessageInfo msg2 = (JwmaMessageInfo) o2;
046:                    return msg2.getDate().compareTo(msg1.getDate());
047:                }//compare(Object,Object)
048:            };
049:
050:            /**
051:             * Defines a <tt>Comparator</tt> that sorts
052:             * the receive date chronological (i.e. oldest first).
053:             */
054:            public static final Comparator RECEIVE_CHRONOLOGICAL = new Comparator() {
055:
056:                public int compare(Object o1, Object o2) {
057:                    JwmaMessageInfo msg1 = (JwmaMessageInfo) o1;
058:                    JwmaMessageInfo msg2 = (JwmaMessageInfo) o2;
059:                    return msg1.getReceivedDate().compareTo(
060:                            msg2.getReceivedDate());
061:                }//compare(Object,Object)
062:            };
063:            /**
064:             * Defines a <tt>Comparator</tt> that sorts
065:             * the receive date reverse to chronological
066:             * (i.e. most recent first).
067:             */
068:            public static final Comparator RECEIVE_REVERSE_CHRONOLOGICAL = new Comparator() {
069:
070:                public int compare(Object o1, Object o2) {
071:                    JwmaMessageInfo msg1 = (JwmaMessageInfo) o1;
072:                    JwmaMessageInfo msg2 = (JwmaMessageInfo) o2;
073:                    return msg2.getReceivedDate().compareTo(
074:                            msg1.getReceivedDate());
075:                }//compare(Object,Object)
076:            };
077:
078:            /**
079:             * Defines a <tt>Comparator</tt> that sorts
080:             * the send date chronological (i.e. oldest first).
081:             */
082:            public static final Comparator SEND_CHRONOLOGICAL = new Comparator() {
083:
084:                public int compare(Object o1, Object o2) {
085:                    JwmaMessageInfo msg1 = (JwmaMessageInfo) o1;
086:                    JwmaMessageInfo msg2 = (JwmaMessageInfo) o2;
087:                    return msg1.getSentDate().compareTo(msg2.getSentDate());
088:                }//compare(Object,Object)
089:            };
090:
091:            /**
092:             * Defines a <tt>Comparator</tt> that sorts
093:             * the send date reverse to chronological
094:             * (i.e. most recent first).
095:             */
096:            public static final Comparator SEND_REVERSE_CHRONOLOGICAL = new Comparator() {
097:
098:                public int compare(Object o1, Object o2) {
099:                    JwmaMessageInfo msg1 = (JwmaMessageInfo) o1;
100:                    JwmaMessageInfo msg2 = (JwmaMessageInfo) o2;
101:                    return msg2.getSentDate().compareTo(msg1.getSentDate());
102:                }//compare(Object,Object)
103:            };
104:
105:            /**
106:             * Defines a <tt>Comparator</tt> that sorts
107:             * the sender or receiver string lexographical.
108:             */
109:            public static final Comparator WHO_LEXOGRAPHICAL = new Comparator() {
110:
111:                public int compare(Object o1, Object o2) {
112:                    JwmaMessageInfo msg1 = (JwmaMessageInfo) o1;
113:                    JwmaMessageInfo msg2 = (JwmaMessageInfo) o2;
114:                    return msg1.getWho().compareTo(msg2.getWho());
115:                }//compare(Object,Object)
116:            };
117:
118:            /**
119:             * Defines a <tt>Comparator</tt> that sorts
120:             * the sender or receiver string reverse lexographical.
121:             */
122:            public static final Comparator WHO_REVERSE_LEXOGRAPHICAL = new Comparator() {
123:
124:                public int compare(Object o1, Object o2) {
125:                    JwmaMessageInfo msg1 = (JwmaMessageInfo) o1;
126:                    JwmaMessageInfo msg2 = (JwmaMessageInfo) o2;
127:                    return msg2.getWho().compareTo(msg1.getWho());
128:                }//compare(Object,Object)
129:            };
130:
131:            /**
132:             * Defines a <tt>Comparator</tt> that sorts
133:             * the sender string lexographical.
134:             */
135:            public static final Comparator SENDER_LEXOGRAPHICAL = new Comparator() {
136:
137:                public int compare(Object o1, Object o2) {
138:                    JwmaMessageInfo msg1 = (JwmaMessageInfo) o1;
139:                    JwmaMessageInfo msg2 = (JwmaMessageInfo) o2;
140:                    return msg1.getFrom().compareTo(msg2.getFrom());
141:                }//compare(Object,Object)
142:            };
143:
144:            /**
145:             * Defines a <tt>Comparator</tt> that sorts
146:             * the sender string reverse lexographical.
147:             */
148:            public static final Comparator SENDER_REVERSE_LEXOGRAPHICAL = new Comparator() {
149:
150:                public int compare(Object o1, Object o2) {
151:                    JwmaMessageInfo msg1 = (JwmaMessageInfo) o1;
152:                    JwmaMessageInfo msg2 = (JwmaMessageInfo) o2;
153:                    return msg2.getFrom().compareTo(msg1.getFrom());
154:                }//compare(Object,Object)
155:            };
156:
157:            /**
158:             * Defines a <tt>Comparator</tt> that sorts
159:             * the receiver string lexographical.
160:             */
161:            public static final Comparator RECEIVER_LEXOGRAPHICAL = new Comparator() {
162:
163:                public int compare(Object o1, Object o2) {
164:                    JwmaMessageInfo msg1 = (JwmaMessageInfo) o1;
165:                    JwmaMessageInfo msg2 = (JwmaMessageInfo) o2;
166:                    return msg1.getTo().compareTo(msg2.getTo());
167:                }//compare(Object,Object)
168:            };
169:
170:            /**
171:             * Defines a <tt>Comparator</tt> that sorts
172:             * the receiver string reverse lexographical.
173:             */
174:            public static final Comparator RECEIVER_REVERSE_LEXOGRAPHICAL = new Comparator() {
175:
176:                public int compare(Object o1, Object o2) {
177:                    JwmaMessageInfo msg1 = (JwmaMessageInfo) o1;
178:                    JwmaMessageInfo msg2 = (JwmaMessageInfo) o2;
179:                    return msg2.getTo().compareTo(msg1.getTo());
180:                }//compare(Object,Object)
181:            };
182:
183:            /**
184:             * Defines a <tt>Comparator</tt> that sorts
185:             * the message number numerical (i.e. lowest first).
186:             */
187:            public static final Comparator NUMBER_NUMERICAL = new Comparator() {
188:
189:                public int compare(Object o1, Object o2) {
190:                    JwmaMessageInfoImpl msg1 = (JwmaMessageInfoImpl) o1;
191:                    JwmaMessageInfoImpl msg2 = (JwmaMessageInfoImpl) o2;
192:                    return msg1.getNumberForSort().compareTo(
193:                            msg2.getNumberForSort());
194:                }//compare(Object,Object)
195:            };
196:
197:            /**
198:             * Defines a <tt>Comparator</tt> that sorts
199:             * the message number reverse numerical (i.e. highest first).
200:             */
201:            public static final Comparator NUMBER_REVERSE_NUMERICAL = new Comparator() {
202:
203:                public int compare(Object o1, Object o2) {
204:                    JwmaMessageInfoImpl msg1 = (JwmaMessageInfoImpl) o1;
205:                    JwmaMessageInfoImpl msg2 = (JwmaMessageInfoImpl) o2;
206:                    return msg2.getNumberForSort().compareTo(
207:                            msg1.getNumberForSort());
208:                }//compare(Object,Object)
209:            };
210:
211:            /**
212:             * Defines the relation between a given criteria and a
213:             * comparator.
214:             */
215:            public static final Comparator[] CRITERIA_COMPARATOR = {
216:                    RECEIVE_CHRONOLOGICAL, //0
217:                    RECEIVE_REVERSE_CHRONOLOGICAL, //1
218:                    SEND_CHRONOLOGICAL, //2
219:                    SEND_REVERSE_CHRONOLOGICAL, //3
220:                    RECEIVER_LEXOGRAPHICAL, //4
221:                    RECEIVER_REVERSE_LEXOGRAPHICAL, //5
222:                    SENDER_LEXOGRAPHICAL, //6
223:                    SENDER_REVERSE_LEXOGRAPHICAL, //7
224:                    NUMBER_NUMERICAL, //8
225:                    NUMBER_REVERSE_NUMERICAL, //9
226:                    DATE_CHRONOLOGICAL, //10
227:                    DATE_REVERSE_CHRONOLOGICAL, //11
228:                    WHO_LEXOGRAPHICAL, //12
229:                    WHO_REVERSE_LEXOGRAPHICAL //13
230:            };
231:
232:        }//class MessageSortingUtil
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.